Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
82
rated 0 times [  86] [ 4]  / answers: 1 / hits: 48426  / 11 Years ago, thu, july 4, 2013, 12:00:00

Should be verry easy but I can't get it to work. As described in the title I would like to change onmouseover the background-color from span.name (orange)



<div class=pdf-icon-box style=position:relative; onmouseover=this.style.backgroundColor = 'yellow'; onmouseout=this.style.backgroundColor = 'green'; >
<span class=pdf-style>
<span class=name style=display:inline-block;background-color:orange;> T E S T </span>
</span>
</div>


I found this but coul'd not get it to work
Get Element By using Class name



This is what I'm trying: fiddle is here



It only has to work in FF



Thanks for help!


More From » html

 Answers
10

Modifying your code



<div class=pdf-icon-box style=position:relative; onmouseover=this.getElementsByClassName('name')[0].style.backgroundColor = 'yellow'; onmouseout=this.getElementsByClassName('name')[0].style.backgroundColor = 'green'; >
<span class=pdf-style>
<span class=name style=display:inline-block;background-color:orange;> T E S T </span>
</span>
</div>


Demo: Fiddle


[#77204] Wednesday, July 3, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
havenbilliec

Total Points: 324
Total Questions: 106
Total Answers: 94

Location: Pitcairn Islands
Member since Fri, Oct 15, 2021
3 Years ago
;