Link to home
Start Free TrialLog in
Avatar of FairyBusiness
FairyBusinessFlag for United States of America

asked on

HELP with undefined variable in my jquery??

Hi,

This was coming up undefined (in my web developer tools in firefox):

var slider = $("article.slider");
var right = ($(slider).css("right")).length - 2;
var left = ($(slider).css("left")).length - 2;

Open in new window


So I put these variables in an if statement because on another page they are needed.

   
var slider = $("article.slider");
if (slider) {
        var right = ($(slider).css("right")).length - 2;
        var left = ($(slider).css("left")).length - 2;
}

Open in new window


So basically I am trying to say if this element exists on the page (article.slider) then set these variables.  If not just ignore them. But they are still coming up undefined.  Anyone know how to accomplish this??
Avatar of Deja Anbu
Deja Anbu
Flag of Oman image

try with

var slider = $("article.slider");
if (slider) {
        var right = (slider.css("right")).length - 2;
        var left = (slider.css("left")).length - 2;
}

Open in new window

Avatar of FairyBusiness

ASKER

nope that didn't make a difference.
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks!! =)