开发者

if url is AllItems.aspx then display none else AllItems.aspx?ID= display block

开发者 https://www.devze.com 2023-03-02 03:11 出处:网络
the script below doesn\'t seem to work! what\'s wrong with it? here is what i try to do: if url is AllItems.aspx then display:none else AllItems.aspx?ID= display:block开发者_JS百科

the script below doesn't seem to work!

what's wrong with it?

here is what i try to do:

if url is AllItems.aspx then display:none else AllItems.aspx?ID= display:block

开发者_JS百科
var url = location.pathname;
  if (document.URL.indexOf("AllItems.aspx")>= 0)  {
  jQuery("#logo").css("display","none");
  }
    else if (document.URL.indexOf("AllItems.aspx?ID=")>= 0)  {
  jQuery("#logo").css("display","block");
  }


the ?xxx part of URL can be read by location.search, thus the code may be:

if (location.search.length <= 1) { // may be only a '?'
    $('#logo').hide();
}
else {
    $('#logo').show();
}
0

精彩评论

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