zoukankan      html  css  js  c++  java
  • 记录最近工作使用javascript对select[option]的操作

    1:

    数据库取值赋予select选项

        $(function(){
            $("input[name='state'][value='{$store.state}']").attr("checked",'checked');
        }) 
     

    2:

    将select[option]中选中的选项值和文字分别赋予两个input[hidden]输入框

    $("select[class='cate']").change(function(){
        if($(this).find('option:selected').text() != '请选择...')
        {
            $("#cate_name").val($(this).find('option:selected').text());
        }
        else
        {
            $("#cate_name").val('');
        }
    });
     
    $("select[class='state']").change(function(){
        if($(this).find('option:selected').text() != '请选择...')
        {
            $("input[name='state']").val($(this).val());
        }
        else{
            $("input[name='state']").val(0);
        }
    })
  • 相关阅读:
    进度条
    html5 表单新增事件
    html5 表单的新增type属性
    html5 表单的新增元素
    html5 语义化标签
    jq 手风琴案例
    codeforces 702D D. Road to Post Office(数学)
    codeforces 702C C. Cellular Network(水题)
    codeforces 702B B. Powers of Two(水题)
    codeforces 702A A. Maximum Increase(水题)
  • 原文地址:https://www.cnblogs.com/logon/p/3186517.html
Copyright © 2011-2022 走看看