javascript - Add jQuery to WordPress page -


i need add jquery library wordpress page. page rendered plugin shortcode.

i've used below methods don't see working jquery script.

i tried add these below script in main plugin file plugin name , version go.

desn't work:

function my_init() {     if (!is_admin()) {         wp_enqueue_script('jquery');     } } add_action('init', 'my_init'); 

desn't work

function my_init() {     if (!is_admin()) {         // comment out next 2 lines load local copy of jquery         wp_deregister_script('jquery');          wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js', false, '1.4.2');          wp_enqueue_script('jquery');     } } add_action('init', 'my_init'); 

i need add below library wordpress front end page?

http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js 

but if use directly below works.

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> 

second, how can see loaded in browser loaded along other code?

if want add script in wp-admin use admin_head or if want add script on front-end use wp_head in place of admin_head

un-register jquery scripts , call function add custom script.

add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );  function my_deregister_javascript() {     wp_deregister_script( 'jquery' ); }      function add_custom_script() {         if (!is_admin()) {               wp_enqueue_script('jquery_host', "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" , array('jquery'));          }     }     add_action('admin_head', 'add_custom_script'); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -