Jump to content

Change CSS


adam84

Recommended Posts

I am having trouble changing an elements css class. What I want is when the div element is clicked, i want to change to style sheet so that it has the border around it.

 

Thanks

 

//html

<html>
<head>
	<link rel="stylesheet" type="text/css" href="test.css" id="test"/>

	<script>
		function divClick(id){
document.getElementById(id).setAttribute("class", "test");

		}
	</script>
</head>

</body>

	<br /><br />

	<div name="myDiv" id="myDiv" onclick="javascript:divClick(this.id);">This is a test</div>

</body>


</html>

 

//css

.highlight{ 
border: .2em dotted #900; 
} 

#border { 
border-width: .2em; 
border-style: dotted; 
border-color: #900; 
} 

Link to comment
https://forums.phpfreaks.com/topic/162809-change-css/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.