2014年5月5日 星期一

運用jQuery搜尋Table中特定條件select option 的資料

直接看程式碼

function test2(){
$("tr").each(function(i){
//取得符合條件checkbox的value
//var checkboxValue = $(this).find("input[type='checkbox']").attr('checked');
var checkboxValue = $(this).find("td input[type='checkbox']").attr('checked');

if(checkboxValue==true)
//取得在該tr中符合條件的value
var tmp = $(this).find("select option:selected").attr('value');
//console.log(checkboxValue);
if(tmp!=null){
console.log(tmp);
}
});
}

大意是找出整份文件中 tr 中符合 ("input[type='checkbox']").attr('checked')
條件的 row,找到該row 後,再依照 ("select option:selected"),取得想要的值

沒有留言:

張貼留言

Related Posts Plugin for WordPress, Blogger...