js中循环遍历

来源:互联网 发布:国家旅游局数据统计 编辑:程序博客网 时间:2024/06/05 03:16

循环遍历name相同的textarea 校验是否有值  

<c:forEach items="${contractGenerationList}" var="contractGeneration" varStatus="st">

     <tr>

               <c:if test="${textFlag==1}">

             <td name="recordingPrintTd">
                     <textarea name="recordingPrint" style="width:90%" rows="4" cols="10"

                      style="font-size:px" onblur="checkData1(this);"></textarea><span class="r_star"  id="textSpanId"></span>
             </td>
            </c:if>

     </tr>

</c:forEach>

$("textarea[name='recordingPrint']").each(function(){
   if(this.value == null || this.value =='' ){
    this.nextSibling.innerHTML="请填写补打原因!";
    return false;
   }else{
    this.nextSibling.innerHTML = "";
   }
  });

循环遍历name相同的Input 'text'校验是否有值 

$("input[type='text'][name='printNum']").each(function(){
   if(this.value.isInt() == false){
    this.nextSibling.nextSibling.innerHTML = "请填写整数!";
    this.focus();
    return false;
   }else{
    this.nextSibling.nextSibling.innerHTML = "";
   }
  });

循环遍历checkbox 全选

$("#checkAll").click(function() {
  if ($(this).attr("checked") == true) {
   $("input[type='checkbox']").each(function() {
    $(this).attr("checked", true);
   });
  } else {
   $("input[type='checkbox']").each(function() {
    $(this).attr("checked", false);
   });
  }
 });

原创粉丝点击