Reputation: 749
I cant help but feel stupid. I have a simple setup which should be working but is not. Obviously im missing something simple. Im trying to get it to load on doc ready rather than using window scroll btw.
why does this not work?
if ($(".container").css("width") == "100%"){
alert("adfgf adg df afdgadg");
}
thanks in advance.
Upvotes: 0
Views: 37
Reputation: 1101
use width()
:
if ($(".container").width() == $(window).width()){
alert("adfgf adg df afdgadg");
}
demo: http://jsfiddle.net/bxLLH/3/
Upvotes: 1
Reputation: 458
jQuery seems to only return pixel widths rather than percentages. Try using
if ($('.container').width() === $('.container').parent().width())
That will check to be sure something is the same width as it's direct parent element.
Upvotes: 1