zoukankan      html  css  js  c++  java
  • jquery--获取同一个属性的多个input,和select

    jquery获取同一个属性的多个input值

    <input type="text" name="name"  id="input_name" placeholder="请输入名称">
    <input type="text" name="name"  id="input_name" placeholder="请输入名称">
    $("input[name='name']").each(function(index,item) {
       console.log(this.value)
       })
    jquery获取同一个属性的多个select值
    数据如:
    {{ project_data.choiceSelect }}
    # [{'verbose_name': 'age', 'options': ['11', '22', '33']}, {'verbose_name': 'name', 'options': ['zhangsan', 'li']}]
    {% for choice in project_data.choiceSelect %}
        <div class="form-group">
            <label><input id="choice_name" value="{{ choice.verbose_name }}" disabled style="border: none" name="choice_name"></label>
              <select class="choice_options form-control"  id="choice_options">
                       {% for ds in choice.options %}
                           <option value="{{ds}}" name="choice_options">{{ds}}</option>
                       {% endfor %}
               </select>
       </div>
    {% endfor %}

    var choice_options_list = new Array()
    $(".choice_options").each(function(index,item) {
       choice_options_list.push(this.value)
    })
       console.log(choice_options_list)

    jquery点击增加同样的表单内容

    <div class="form-group">
      <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">日志路径 <span class="required" style="color: red">*</span>
      </label>
      <div class=" logs col-md-6 col-sm-6 col-xs-12" >
        <input type="text" id="logPath" required="required" name="logPath" class="form-control col-md-7 col-xs-12">
      </div>
    </div>
      <input type="button" value="添加" onclick="add()">
    
    // 添加日志输入框函数
        var addLog = '<input type="text" id="logPath" required="required" name="logPath" class="form-control col-md-7 col-xs-12">'
    
        function add() {
            $(".logs").append(addLog)
    
        }
     
  • 相关阅读:
    CentOS开发环境LAMP搭建
    Oracle中*.dpm文件导入
    SQL Server查询数据库中所有的表名及行数
    SQL Server数据库同步SQL
    Vim 快捷键整理
    SQL Server解决死锁问题
    python重试装饰器的简单实现
    神奇的描述符(三):覆盖描述符与非覆盖描述符
    神奇的描述符(二):使用描述符实现实例属性的类型检查
    神奇的描述符(一):描述符协议的实现
  • 原文地址:https://www.cnblogs.com/lutt/p/12723397.html
Copyright © 2011-2022 走看看