jquery为某div下的所有textbox的赋值

html代码

<input type="button" value="变量div_Alltext中的变量" onclick="Do_DivAllTxt()"/>

<div id="div_alltext" style="background-color:#FCC">
<input type="text" name ="txtx"/>
<input type="text" name ="txtx"/>
<input type="text" name ="txtx"/>
<input type="text" name ="txtx"/>
<input type="text" name ="txtx"/>
 </div>

js代码

function Do_DivAllTxt()
{
 var alltxt = $("#div_alltext input[name=txtx]"); //关键点,通过表单属性input[name=txtx]; ,找到div下的txtbox
 $.each(alltxt,function(i){
       $(this).val("ok");
         });
 }

原文地址:https://www.cnblogs.com/Ellfelo/p/jquery.html