Pass Shortcode Attribute to footer Script

It’s simple. WordPress have a handy function to send variables to a registered script. It’s wp_localize_script. It work this way:

//First Register Your Script
wp_register_script( 'name-of-script', 'http://example.com/script.js', '', '', true );

//Then send dynamic variables
wp_localize_script( 'name-of-script', 'globalVar', array( 'id' => 'slideTarget' ) );

//Finally invoke it on Front-End
wp_enqueue_script ( 'name-of-script' );

This should outputted before the script is called, and since it’s called on footer, you can just call it inside your shortcode function. Then, on your script, you will need to use it like this:

$("#" + globalVar.id ).bxSlider({

Simple as that. There are other options as well, like outputting a global var or outputting a hidden input with the target ID, so you script would just need to looking for that hidden input value.