Hi I would like to change a css rule,with javascript this is what i have so far??

body{
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	/* [disabled]line-height: 17px; */
	color: #ffffff;
	background: url(images/bg.jpg);

<script>

function changeStyle()
{

var mySheet = document.styleSheets[0].rules || document.styleSheets[0].cssRule;
for(var i=0; i<mySheet.length;i++)
{
if(mySheet[i].selectorText == "body")
targetRule = mySheet[i];
targetRule= "background:#000000";

}




</script>

}

Thanks in advance!

Recommended Answers

All 3 Replies

Member Avatar for stbuchok

Look at using jQuery. Specifically the css() method. Trust me, it helps.

I'll look into that thanks

is it possible to change an external style sheet using the css method?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.