jquery 输入值选择器

标签 jquery input jquery-selectors

我这里有代码..

 <div>
    <input type="hidden" value="hello" />
 </div>

 <div>
    <input type="hidden" value="world" />
 </div>

是否可以选择内部值为“hello”的div并将所选div的颜色更改为红色...?

 $("div input[value='hello']").css("background","red"); //i have this in mind
                                                        //but i think its wrong:D

请帮忙..

最佳答案

您想要选择输入,然后获取其父级div:

$("input[value='hello']").parent("div").css("background", "red");

关于jquery 输入值选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5060652/

相关文章:

jquery - 在 Django 中实现过滤/搜索的最佳方法

javascript - Jquery 和 Bootstrap 在 Firefox 中不工作

等待用户输入特定秒数的 C 程序

jquery - 如何在jquery中创建和访问数组

javascript - 使用 eq() 和 find() 添加类

php - 简单的 JSON 解析

javascript - IMDB 评级插件不适用于 ajax

html - 如何为输入中显示的文本创建偏移量?

javascript - 让一个输入字段自动更新另一个输入字段,反之亦然(可能使用 JavaScript)

jquery - 使用 :contains() Selector on a label to affect an input