如何找到带有“value=x"的元素? [英] How to find elements with 'value=x'?

查看:20
本文介绍了如何找到带有“value=x"的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要删除具有 value="123" 的元素.我知道所有具有不同值的元素都位于 #attached_docs 中,但我不知道如何使用 value="123" 选择元素.

I need to remove element that have value="123". I know that all elements with different values are located into #attached_docs, but I don't know how to select element with value="123".

$('#attached_docs').find ... .remove();

你能帮我吗?

推荐答案

如果使用 value 属性将值硬编码到页面源代码中,那么您可以

If the value is hardcoded in the source of the page using the value attribute then you can

$('#attached_docs :input[value="123"]').remove();

如果要定位具有 123 值的元素,该值由用户设置或以编程方式设置,然后使用编辑 双向工作 ..

If you want to target elements that have a value of 123, which was set by the user or programmatically then use EDIT works both ways ..

$('#attached_docs :input').filter(function(){return this.value=='123'}).remove();

演示 http://jsfiddle.net/gaby/RcwXh/2/

这篇关于如何找到带有“value=x"的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆