Reputation: 9362
I need to check my radio button manually like below. But the problem is that the event is not fired (when checked manually).
$(function () {
// always check the 1st element
$("input:radio[name=MatrixID]:first").attr('checked', true).click();
});
$('.editor-field > input[type=radio]').change(function () {
// !!! not fired when checked by code!!??
p.mustSave = true;
});
My question: how to check manually (by code) my radio button and also trigger change event?
My html:
<p>
<span class="editor-field">
<input name="MatrixID" id="MatrixID873" type="radio" checked="checked" value="873"/>
</span>
</p>
Thanks a lot.
Upvotes: 0
Views: 2494
Reputation: 33880
.click()
trigger click event, but you are using change()
. Try this instead :
$("input:radio[name=MatrixID]:first").prop('checked', true).trigger('change');
Upvotes: 2