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
Post a Comment