I have an URL like this:
http://mysite.com/something/view/something-else/
I want to hide all the images with the class .attachment inside all the pages that have the /view/ part in the URL using jQuery.
Any suggestions to accomplish this?
I have an URL like this:
http://mysite.com/something/view/something-else/
I want to hide all the images with the class .attachment inside all the pages that have the /view/ part in the URL using jQuery.
Any suggestions to accomplish this?
It would be something like this
var url = window.location.pathname;
if(url.indexOf('/view/') >= 0){
$('.attachment').css('display','none');
}
Here is an example... you need to click Run to see it work.
url.indexOf('/view/') >= 0 since '/view/' can be at the beginning of the pathname so indexOf() could find it and return 0.url.indexOf('/view/') != -1url.indexOf('/view/') != -1 as well.