开发者

jquery hash if no hash

Trying to get #home to display if there is no hash present in the url. I figured something along these lines would work pretty easy but I can't get anything going:

   if(window.location.hash != null){ 
      $(window.location.hash).fadeIn(800);
   } else {
      $('#home').fadeIn(开发者_JAVA技巧800);
   }

I've never worked with if / else statements in jquery, so this is obviously wrong

thanks!


Compare it against the empty string instead (null and the empty string aren't equal in JavaScript):

if(window.location.hash != ''){ 
   $(window.location.hash).fadeIn(800);
} else {
   $('#home').fadeIn(800);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜