Detect a Variable Exists in jQuery -


hello rather new jquery , have situation here.

i setting default position on document.ready below

$('.categorytitle').scrollto($(".people .sants a.modeling").attr('href'), 750, {easing:'easeoutexpo'}); 

now works when placed on page containing .categorytitle class

the issue arises when script cannot find .categorytitle class in document

i tried below code did not work

if($('.categorytitle').length!= 0){      $('.categorytitle').scrollto($(".people .sants a.modeling").attr('href'), 750, {easing:'easeoutexpo'}); } 

can on way can find if .categorytitle exists in page?

many thanks!

this complete code trying implement.

        if($('.categorytitle').length){         $('.categorytitle').scrollto($(".people a.modeling").attr('href'), 750, {easing:'easeoutexpo'});         }         if($('.categorytext').length){         $('.categorytext').scrollto($(".people a.modeling").attr('href'), 750, {easing:'easeoutexpo'});         }         if($('.models').length){         $('.models').scrollto($(".people a.modeling").attr('href'), 750, {easing:'easeoutexpo'});         } 

i "f undefined" jquery scrollto script file. seems $(".people .sants a.modeling").attr('href') undefined , error.

if($('.categorytitle')){      $('.categorytitle').scrollto($(".people .sants a.modeling").attr('href'), 750, {easing:'easeoutexpo'}); } 

try one


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -