Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can only change an inline style, tag-style won't work

Status
Not open for further replies.

iostream71

Programmer
Mar 13, 2002
229
US
this is a really bad example, but general idea of what i want to do. trying to change the color of the element's text on a click. will only work if i do it inline. i read about using document.styleSheets[n].cssRules[n], but that wouldn't work either

<head>

<style type=&quot;text/css&quot;>
p { color:red }
</style>

<script language=&quot;javascript&quot;>
function changeIt(){
document.getElementById('myId').style.color = &quot;blue&quot;;
}
</script>

</head>
.
.
.
<body>
<p id=&quot;myId&quot; onClick=&quot;changeIt()&quot;> my text </p>
 
ok, this is really weird. i decided since you said it worked in ie5, to try again, but hard-code it(was using dreamweaver). it worked fine....exact same code too. for some reason, i won't work if i publish it through dreamweaver...??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top