Reputation: 49422
Using JQuery I am looking for a way to Click on an Input which contains a certain value.
For example:
<input type="button" class="myclass" value="one" />
<input type="button" class="myclass" value="two" />
How can I get JQuery to click on the button that contains the value of "two" for example?
Upvotes: 0
Views: 71
Reputation: 20293
Try this:
$('input.myclass[type="button"][value="two"]').click(function(){
});
or
$('input.myclass[type="button"][value="two"]').trigger('click');
Upvotes: 1
Reputation: 62498
Like this:
$('input.myclass[value="two"]').click(); // programmatically clicked
$('input.myclass[value="two"]').click(function(){ // event handler for click
alert('clicked');
});
Upvotes: 1
Reputation: 67217
Try,
$('input.myclass[value="two"]').click();
or
$('input.myclass[value="two"]').trigger('click');
Upvotes: 3