Make a <div> disappear inside a javascript script

Posted by KeenClock on Stack Overflow See other posts from Stack Overflow or by KeenClock
Published on 2012-03-18T22:44:19Z Indexed on 2012/03/19 2:03 UTC
Read the original article Hit count: 195

Filed under:
|

First of all, I have this line of code on a random page :

<script type="text/javascript" src="script.php"></script>

On the page named "script.php", I have a <div class="something">random text</div> and the random text is displayed and everything is working fine.

Now, I would like to know if it's possible to make that specific <div> to disappear without having to modify the code inside the "script.php" page.

Thank you !

Edit:

Thank you to all of you, you helped me found a solution, here is an example :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Random page</title>
<style type="text/css">
div.something
{
font-family: Tahoma;
font-size: 12px;
font-weight: bold;
text-decoration: underline;    
}
</style>
<script type="text/javascript">
function hideSomething()
{
document.getElementsByClassName("something")[2].style.display = "none";
}
</script>
</head>
<body>
<div class="something">random text 1</div>
<div class="something">random text 2</div>
<div class="something">random text 3</div>
<br /><input type="submit" value="Disappear" onclick="hideSomething()" />
</body>
</html>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about css