Hide a div/link without any id

Hello,

Please look at following html:

<div style=“padding-bottom: 4px;”>
<img height=“10” align=“absmiddle” width=“10” src=“images/1rightarrow.gif”> <a class=“mainmenu” href=“affiliate-settings.php”>Inoutscripts Affiliate Id </a>
</div>

Now, can someone please suggest that is there a way to hide this div or link in javascript/jquery? I can’t make use of class as well because there are several links as well with the same class name.

Thanks in advance,
Kul.

If you need to target the div, either place a unique identifier on the div or a class that appropriately represents the purpose of the object.

Why are you hiding it. Is it because that it is content that only logged in affiliates are supposed to see? If so, give the div a class name of “affiliate user” and apply style to the user class. Only apply a style to the affiliate class when that style applies only to affiliate and no other user-based style.

when are they supposed to be hidden? should one be hidden and the rest showing? are they supposed to become hidden after a mouse click?

Yes, u r right, but, my issue is that i can’t edit existing code,its, encoded, need to put in my code on the page for the same existing code that i posted above.

Is it possible to achieve?

Actually i don’t want that link to appear when the page is viewed, so, on pageload i suppose.

so its just the one div then that is supposed to be hidden? couldn’t you just do like this

function hide() {
document.getElementById(‘hiddenDiv’).style.visibility = ‘hidden’;
}
</head>
<body.onload=“hide()”>
<div style=“padding-bottom: 4px;” id=“hiddenDiv”>
<img height=“10” align=“absmiddle” width=“10” src=“images/1rightarrow.gif”> <a class=“mainmenu” href=“affiliate-settings.php”>Inoutscripts Affiliate Id </a>
</div>

bad code, but…

Nops buddy u didn’t get me, i can’t put that id “hiddenDiv” for that div, b’coz i can’t edit it.

var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; ++i) {
    if (links[i].href.toLowerCase().indexOf("affiliate-settings.php") >= 0) {
        links[i].parentNode.style.display = "none";
        break;
    }
}