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)

    }

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM