Bdfy
Bdfy

Reputation: 24621

How to find/remove input in form by value?

How to find/remove input element in form by value ?

Upvotes: 0

Views: 433

Answers (2)

mu is too short
mu is too short

Reputation: 434635

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/

Upvotes: 2

Kiley Naro
Kiley Naro

Reputation: 1769

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/

Upvotes: 0

Related Questions