jquery - If $(element) hasClass then .animate() not working? -


im working on animating arrow when element has class of "activeslide" reason not functioning expected. im not sure why is, can provide little insight in im doing wrong?

$(document).ready(function() {  if($('#navitem-2').hasclass("activeslide")){   $("#navarro").animate({marginleft:"220px"}, 500);  }; }); 

thanks!

*update*: here examaple classes change onclick, animation not function: http://jsfiddle.net/somewhereinsf/pn5sx/1/

$(document).ready(function() {     if($('#navitem-2 .activeslide').length > 0)     {          $("#navarro").animate({marginleft:"220px"}, 500);     } } 

this should work 100% under conditions

  • #navitem-2 exists
  • class activeslide child of #navitem-2
  • #navarro exists.

if have console such google chrom developer tools can add logging mechanism in javascript

$.fn.log = function() {     if(loggingenabled && console && console.log)     {         console.log(this);     }     return this; } 

and try:

loggingenabled  = true; $(document).ready(function() {     var check = $('#navitem-2 .activeslide').log();     if(check.length > 0)     {          $("#navarro").log().animate({marginleft:"220px"}, 500);     } } loggingenabled = false; 

and can see what's appearing in log console.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -