jQuery选择器的输入值 [英] jquery Selector for input value
本文介绍了jQuery选择器的输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里有代码.
<div>
<input type="hidden" value="hello" />
</div>
<div>
<input type="hidden" value="world" />
</div>
是否可以选择内部值为"hello"的div并将所选div的颜色更改为红色...?
is it possible to select the div with the value "hello" inside and change the selected div's color to red...?
$("div input[value='hello']").css("background","red"); //i have this in mind
//but i think its wrong:D
请任何帮助.
推荐答案
您要选择输入,然后选择其父div
:
You want to select the input, then take its parent div
:
$("input[value='hello']").parent("div").css("background", "red");
这篇关于jQuery选择器的输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文