-2

here is my code-snippet:

    <div id="navbar">
        <a href="index.html" >
        <img class="navbar" src="http://ssss.com/imgs/WG_home.png" />
        </a>Home
    </div>



    function used to hide:

    $(document).ready(function() { 
     alert("hello");
    if (location.search=="?value=nohome")
       {
        $("img[class='navbar']").hide();
       }

 });

Any one having any idea how to hide the image?

mrana

4

3 回答 3

2

Try this instead:

if (window.location.href.indexOf("nohome") >= 0)
{
   $("img.navbar").hide(); // changed...........
}

Notice that instead of $("img[class='navbar']"), you can simply use $("img.navbar") or $(".navbar") if navbar is applied only on images you want to target.

于 2012-05-07T11:02:31.650 回答
1

Try

 $(document).ready(function() { 

if (location.href.indexOf("nohome") >= 0)
   {
    $("img[class='navbar']").hide();
   }

});​</p>

Here is the fiddle

于 2012-05-07T11:16:30.413 回答
0

try

$('.navbar']).hide();

make use of class selector insted of the selector you use ..

EDIT

To hide only one image out of 10-15 image with the same class , in that case you cannot go for class selector you need to make use of id selector which uniquelly identify the image...("#id").hide();

于 2012-05-07T11:03:40.370 回答