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

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

问题描述

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

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

您能帮我吗?

解决方案

如果使用属性在页面的源代码中对值进行硬编码,那么您可以

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

如果您要定位具有 123 ,这是由用户设置或以编程方式,然后使用
编辑 两种方式 ..



$或者

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

demo http://jsfiddle.net/gaby/RcwXh/2/


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();

Can you help me?

解决方案

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

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

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 ..

or

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

demo http://jsfiddle.net/gaby/RcwXh/2/

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

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