Im trying to check the position of an element on this page, and if its below a certain point I want to change the font color to something readable, but .position and .offset(which is what I should be using) are both returning NULL.
Here is my jquery, the alert is in there for testing purposes:
var position = $("#about_tattoo").offset();
alert("top: "+ position.top);
if(position.top >= 1000){
$("#about_tattoo").css("color","white");
}
and there i开发者_Python百科s a div on the page: <div id="about_tattoo">
its working here
http://jsfiddle.net/smd8b/
make sure you have wrapped the code in
$(function(){
...
});
精彩评论