Yea*_*eak 2 html javascript jquery
我有几个表行和表,其中包含隐藏的输入字段和值.我需要做的是遍历所有隐藏的输入字段并找到一个特定的字段,其中class ='something'和value = something并转到<td>该输入字段并更改背景颜色.
$('input:hidden').each(function(){
if( $(this).find(".id_schedule_hours") && $(this).val() == 1) {
console.log('here')
}
}
Run Code Online (Sandbox Code Playgroud)
.each()没有必要; 你可以使用属性选择器,.closest()
$("input:hidden[class='something'][value='something']")
.closest("td").css("backgroundColor", /* color */)
Run Code Online (Sandbox Code Playgroud)