Reputation: 2349
I want to target this input and change it dynamically with jQuery:
<select id="sub_cat" style="" name="sub_cat">
<option selected="selected" value="-10">All</option>
I want to be able to change 'All' with an if statement based on different variables. Is this possible with jQuery? And how? Any help is appreciated. Thanks
Upvotes: 0
Views: 90
Reputation: 142947
This will change the value of the selected option depending on the value of a lang
variable.
$("#sub_cat option").each(function() {
var option = $(this);
var val = option.val();
if(val === "All") option.val("Hepsi");
});
Upvotes: 1
Reputation: 50503
var option = $('#sub_cat').find('option:contains("All")');
option.text('New Text');
Upvotes: 1