开发者

.position() and .offset returning NULL off my target

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(){
...
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜