Reputation: 1172
I have a confusion, I have a scenario like this:
<div id="min1"></div>
<div id="max1"></div>
<div id="min2"></div>
<div id="max2"></div>
I am using this :
$("[id^=min]", "[id^=max]").val('hello')
to manipulate them. It doesn't work. What is the problem ?
Upvotes: 0
Views: 20
Reputation: 370679
When using $
to select elements, only pass a single selector string as an argument, not multiple different arguments. Separate each different selector by a comma. Also, to set the text of a non-input-like element, use .text()
, not .val()
:
$("[id^=min], [id^=max]").text('hello');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="min1"></div>
<div id="max1"></div>
<div id="min2"></div>
<div id="max2"></div>
Upvotes: 1