How to find/remove input in form by value?
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/
精彩评论