<input type="text" id="test_value" name="test_value" value="xyz" />
<input id="test_default" name="test_default" type="checkbox" onclick="with(this.form.elements['test_value']) { disabled = this.checked; if (this.checked) { value = ''; } else {if(value=='') {value=' '; value = '';}}};" />
The inline onclick is generated by a cms which I have no control of.
I want to execute $("#test_default").click();
with jQuery but that doesn't work because it's not bound to the jQuery event manager.
I've been trying variations of
$("#test_default").click(function (e) {
$(e.target).attr("onclick").apply(checkbox, [e]);
return false;
}).click();
but with no avail. Please Help.
Thanks.
There are dozens of different functions that may be in inline in the onclick. It isn't really an option to duplicate them and run them in parallel.
The answers work in a small demo but not in the live environment. Please look at http://jsfiddle.net/GtJjt/ I need the checkbox to be triggered programatically.
Bizarrely only $("#metadata_field_text_10190_default")[0].click();
triggers the event correctly. Can anyone explain this?