SPECIAL OFFER: Only $69 for access to everything in OSTraining for 1 year! You save $75! 
Join today and get access to 1,000's of books and videos. Learn WordPress, Drupal, Magento, Joomla and more! Sign up today!

jQuery not working

5 years 11 months ago #117563 by Juc2
jQuery not working was created by Juc2
Hi all,

Here is my .js file which shows up in my browser's "View page source", so any ideas please why it is not working ?

Thanks...

Please Log in to join the conversation.

5 years 11 months ago #117573 by Nick
Replied by Nick on topic jQuery not working
Hi Juc2,

Looks like everything's working well, except there's a small syntax error in your jQuery. Please remove the comma after:
alert("hello world")

then it should work for you.

Kind regards,
Nick

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

5 years 11 months ago #117588 by Juc2
Replied by Juc2 on topic jQuery not working
@ Nick it works fine in jsfiddle but it seems it is still not working in Drupal.

Thanks...

Please Log in to join the conversation.

5 years 11 months ago #117604 by Nick
Replied by Nick on topic jQuery not working
Hi Juc2,

Looks like your jQuery is conflicting. Try switching it to:
$.noConflict();
jQuery( document ).ready(function( $ ) {
  // declare a variable
  var $clickme = $('#mars');
 
  // use this variable
  $clickme.on( "click", function() {
      alert("hello world");
  });
});

Kind regards,
Nick

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

5 years 11 months ago #117609 by Juc2
Replied by Juc2 on topic jQuery not working

Nick wrote: Hi Juc2,

Looks like your jQuery is conflicting. Try switching it to:

$.noConflict();
jQuery( document ).ready(function( $ ) {
  // declare a variable
  var $clickme = $('#mars');
 
  // use this variable
  $clickme.on( "click", function() {
      alert("hello world");
  });
});

Kind regards,
Nick


@ Nick here is the updated js file but it seems it is still not working. By the way with my original js file I get

This image is hidden for guests.
Please log in or register to see it.



With your update I get

This image is hidden for guests.
Please log in or register to see it.



Thanks...

Please Log in to join the conversation.

5 years 11 months ago #117613 by Nick
Replied by Nick on topic jQuery not working
OK, try removing the "$.noConflict();" line.

Kind regards,
Nick

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

5 years 11 months ago #117614 by Juc2
Replied by Juc2 on topic jQuery not working

Nick wrote: OK, try removing the "$.noConflict();" line.

Kind regards,
Nick


Ok done but still not working =

This image is hidden for guests.
Please log in or register to see it.

Please Log in to join the conversation.

5 years 11 months ago #117632 by Nick
Replied by Nick on topic jQuery not working
Hi Juc2,

Would you send us some cPanel login credentials to support@ostraining.com so we can take a quick look for you? Also, please do two things for us:
1) In the email, include a link to this forum post
and
2) After sending the email, reply to this forum post letting us know you sent the email so that we can check it.

Looking forward to helping.

Kind regards,
Nick

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

5 years 11 months ago #117641 by Juc2
Replied by Juc2 on topic jQuery not working

Nick wrote: Hi Juc2,

Would you send us some cPanel login credentials to support@ostraining.com so we can take a quick look for you? Also, please do two things for us:
1) In the email, include a link to this forum post
and
2) After sending the email, reply to this forum post letting us know you sent the email so that we can check it.

Looking forward to helping.

Kind regards,
Nick


@ Nick ok I have sent the email - I sent the ftp login if that is ok or let me know if you still need the cpanel login.

Thanks...

Please Log in to join the conversation.

5 years 11 months ago #117661 by Nick
Replied by Nick on topic jQuery not working
Hi Juc2,

Issue resolved. You were running jQuery v1.4.4 on the site. However, .on() was added in version 1.7:
api.jquery.com/on/

I've switched it to .live() for you instead and it works now :)

Kind regards,
Nick

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

5 years 11 months ago #117667 by Juc2
Replied by Juc2 on topic jQuery not working

Nick wrote: Hi Juc2,

Issue resolved. You were running jQuery v1.4.4 on the site. However, .on() was added in version 1.7:
api.jquery.com/on/

I've switched it to .live() for you instead and it works now :)

Kind regards,
Nick


@ Nick, ok great, thanks!

Please Log in to join the conversation.

5 years 11 months ago #117668 by Nick
Replied by Nick on topic jQuery not working
You're very welcome, Juc2!

By the way, congrats on 100 posts! :)

Cheers,
Nick

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

5 years 11 months ago #117672 by Juc2
Replied by Juc2 on topic jQuery not working
@ Nick, thanks

= 101 :)

Please Log in to join the conversation.

5 years 11 months ago #117674 by Nick
Replied by Nick on topic jQuery not working
Cheers :)

Follow us on Twitter - twitter.com/OSTraining
Like us on Facebook - facebook.com/ostraining

Please Log in to join the conversation.

Join today and get access to 1,000's of books and videos. Learn WordPress, Drupal, Magento, Joomla and more! Sign up today!