Using jQuery .find() with multiple conditions at the same time?
- by fuzzybabybunny
I know that there are other ways of grabbing radio button values, but I want to know how to do this with .find().
I only want to log the value of the selected radio button, so it requires finding by two conditions at the same time:
The button with name=area
The button with selected=selected
<div class="radio">
<label>
<input class="track-order-change" type="radio" name="area" id="area1" value="area1" checked="checked">
Area 1
</label>
</div>
<div class="radio">
<label>
<input class="track-order-change" type="radio" name="area" id="area2" value="area2">
Area 2
</label>
</div>
<div class="radio">
<label>
<input class="track-order-change" type="radio" name="area" id="area3" value="area3">
Area 3
</label>
</div>
When anything with the class track-order-change changes, it will run the function UpdateOrderSubmission.
$('.track-order-change').on('change', function() { updateOrderSubmission() });
I want the updateOrderSubmission function to console log the value of the radio button that is selected.
var updateOrderSubmission = function() {
var orderSubmission = {
area: $('#submit-initial-form').find('[name=area],[checked=checked]').this.val()
}
console.log(orderSubmission)
};
The code above doesn't work. How do I grab the value of the selected radio button? I need to do .find() with two conditions (name and checked), not just one condition.