if url is AllItems.aspx then display none else AllItems.aspx?ID= display block
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();
}
精彩评论