首页 > 其他 > 详细

form 中的 table元素过滤定位事件

时间:2017-12-26 18:49:48      阅读:165      评论:0      收藏:0      [点我收藏+]
<form>
    <table>
          <thead>
              <tr>
	             <th>a</th>
	             <th>b</th>
	             <th>c</th>
	             <th>d</th>
	             <th>e</th>
               </tr>
          </thead>
          <tbody>
               <tr class=‘row‘>
                    <td><input type=‘text‘ name=‘1‘ id=‘1‘ ></td>
                    <td><select name=‘o1‘ id=‘o1‘><option></option></select></td>
	            <td><input type=‘text‘ name=‘2‘ id=‘2‘ ></td>
	            <td><input type=‘text‘ name=‘3‘ id=‘3‘ ></td>
                    <td><select name=‘o12‘ id=‘o12‘><option></option></select></td>
               </tr>
          </tbody>
    </table>
</form>        

 

 利用filter过滤选择器对元素集合进行遍历,index表示索引号,obj表示对象,obj.value表示的是获取的值。通过判断获取的值是否为空来给对象的样式进行修改:

$(‘.row‘).find(‘input‘,‘select‘).filter(‘[name$=opc_width],[name$=opc_space],[name$=bias]‘).each(function(index,obj){
         if(obj.value == ‘‘ || obj.value == null || obj.value == "undefined"){
                  $(obj).css(‘border-color‘,‘red‘);
         }else{
                  $(obj).css(‘border-color‘,‘‘);
        }
});

form 中的 table元素过滤定位事件

原文:https://www.cnblogs.com/christal-11/p/8119366.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!