jquery: obtenga múltiples entradas del mismo atributo y seleccione

jquery obtiene múltiples valores de entrada del mismo atributo

<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 obtiene múltiples valores de selección para el mismo atributo
Datos como:

 

{{project_data.choiceSelect}}
# [{'verbose_name': 'age', 'options': ['11', '22', '33']}, {'verbose_name': 'name', 'options': ['zhangsan', 'li ']}]
{% para elegir en 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 " >
                   {% para ds en 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 haga clic para agregar el mismo contenido del formulario

<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 ="requerido "nombre =" logPath "clase =" control de formulario col-md-7 col-xs-12 "> ' function add () { 
        $ ( " .logs " ) .append (addLog) 
    }


    

    

 

 

Supongo que te gusta

Origin www.cnblogs.com/lutt/p/12723397.html
Recomendado
Clasificación