Morpheus
Morpheus

Reputation: 9075

jQuery trigger click on element with "onclick" attribute

I have an input element with onclick attribute attached to it:

<input id="" type="radio" name="" value="" onclick="SetUniqueRadioButton('rptrDelRates.*grpDelRate', this);">

Everything is working good, but when I decide to trigger click manually on this element using jQuery I get the error below:

Invalid regular expression: /rptrDelRates.*grpDelRate/: Stack overflow

jQuery call:

$('.setup-radio').on('click', function () {
    $(this).find('input').trigger('click');      
    return false;
});

Upvotes: 3

Views: 5793

Answers (2)

user2735175
user2735175

Reputation: 1

your SetUniqueRadioButton function must add event.stopPropagation();

code may case loop because of bubble

Upvotes: 0

Milind Anantwar
Milind Anantwar

Reputation: 82251

you can call the native doms onclick directly:

 $(".setup-radio")[0].onclick();

without jquery:

 document.getElementsByClassName("test_default")[0].onclick();

Upvotes: 3

Related Questions