2013-12-09 32 views
0

我有一个ID为'searchForm'的表单中的某些元素。我需要找到所有以“fromDate”结尾的元素,以便我可以执行一些操作,如验证。运行每个函数来查找具有匹配类的元素jquery

下面是一个简单元素

<input type="text" class="FRANCHISEE_openingDatefromDate" name="FRANCHISEE_openingDateFrom" size="17"> 
<script> 
    $('[class^=fromDate]').each(function(index, value){ 
     console.log($(this).attr('id')); 
    }); 
    </script> 

,我想是这样的: - 但是每个循环中的没有得到,可有人指出什么错误或请提供正确的做法/解决方案。

+2

'^ ='意思是 '以' –

回答

0
$("put your certain element").each(function(){ 
    var currentId=$(this).attr("id"); 
    if(currentId.indexOf('fromDate') >= 0){ 
    // perform action to $(this) element 
    } 
}); 
相关问题