Javascript Conditional Logic for Displaying an Image

I have a hardcoded or static image within my web page that I only want to show on the first page of my blog. When the user clicks to page 2, 3, 15, 25 or whatever I do not want the image to display.

The url of the FIRST page is:

The url SECOND and greater pages look like this:

Image I only want to display on "/index" page:
<div class="fullScale offTag"><img src="/image.jpg" alt="" />

Open in new window

Who is Participating?
Michel PlungjanIT ExpertCommented:
if (location.href.indexOf("/index")==-1) {
  document.write('<style>div.fullScale.offTag { display:none }</style>'); // add >img if you want to hide ONLY the image

Open in new window

Rainer JeschorCommented:
can you / do you want to use jQuery for this?
Can this be done by clearing the content of that parent DIV ?
swaggrKAuthor Commented:
Yes, JQuery can be used but I am not sure if clearing the contents of the parent DIV would work or not.
Just don't generate that line of markup when you send pages other than index from the server.

swaggrKAuthor Commented:
@COBOLdinosaur its not that simple. I don't really have control over the server side programming code but I can manipulate the styling, images, divs, etc. using jquery or javascript.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.