开发者

How to find/remove input in form by value?

开发者 https://www.devze.com 2023-04-07 13:41 出处:网络
How to find/remov开发者_StackOverflowe input element in form by value ?You can use filter to cover all the bases:

How to find/remov开发者_StackOverflowe input element in form by value ?


You can use filter to cover all the bases:

var matches = $('input').filter(function() { return this.value == 'what you want' });
matches.remove(); // If you want to remove them of course.

An attribute selector only sees things that have the value attribute set in the DOM so that won't see an <input> that has been updated with a val(x) call, using a filter will see things that have been updated with .val(x).

For example: http://jsfiddle.net/ambiguous/RVWu6/


Making an initial guess at what you're trying to accomplish, you should probably take a look at this question:

How can I select a hidden field by value?

The suggestion there is $('input[value="Whatever"]')

From there you can use the jQuery remove function: http://api.jquery.com/remove/

0

精彩评论

暂无评论...
验证码 换一张
取 消