I have 3 radio buttons which hide/show some div's. The radio buttons are getting generated by a php script, I want jquery to check the first radio button (works already!) and then trigger the click function so it hides/shows the related stuff.
$("input:radio:first").attr("checked", true).trigger("click");
The .trigger("click"); actually does not work.
The click event of the radio buttons looks like this:
$("input[name='type']").on("click", function() { ... });
Any ideas?
To define the click event handler for a button, add the android:onClick attribute to the <RadioButton> element in your XML layout. The value for this attribute must be the name of the method you want to call in response to a click event. The Activity hosting the layout must then implement the corresponding method.
If you are trying to trigger an event on the anchor, then the code you have will work I recreated your example in jsfiddle with an added eventHandler so you can see that it works: $(document). on("click", "a", function(){ $(this). text("It works!"); }); $(document).
Use Google Tag Manager's click trigger to fire tags based on click events. When an element is clicked on a page that matches the trigger conditions, Tag Manager will automatically populate values for any active click-based built-in variables.
Try doing it after DOM ready, like this:
$(function(){
$("input:radio:first").click();
});
Maybe it hasn't finish loading. use .click
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With