Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active March 16, 2017 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/fd0526ccb9047511af2d1302fe39e23a to your computer and use it in GitHub Desktop.
Save Pebblo/fd0526ccb9047511af2d1302fe39e23a to your computer and use it in GitHub Desktop.
Example of how to automatically check the radio button within the ticket selector using jQuery.
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_radio_button_checked() {
wp_add_inline_script(
'ticket_selector',
'jQuery( document ).ready(function($) {
$(".tkt-slctr-tbl").each(function(){
if( $(this).find(".ticket-selector-tbl-qty-slct:radio").length == 1 ){
$(this).find(".ticket-selector-tbl-qty-slct:radio").prop("checked", true);
}
});
});'
);
}
add_action( 'wp_enqueue_scripts', 'tw_ee_radio_button_checked', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment