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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi Folks I've got various blocks

Status
Not open for further replies.

Kenny100

Technical User
Feb 6, 2001
72
NZ
Hi Folks

I've got various blocks of text in my html page that are individually identified using the id tag

e.g. <li id=&quot;216&quot;>This is some text</li>

Next to EACH of these text blocks is a small image. I'd like to include some Javascript on my page so that when I hover over a particular image, it changes the background colour for the text block that the image is positioned next to. Any ideas, tips or links to help me out on this?

Cheers,
Kenny.
 
<script>
function changeBGColour(strObjId, strColorCode){
var objToChange = document.getElementById(strObjId);
objToChange.style.backgroundColor = strColorCode;
}
</script>


<li id=&quot;216&quot;>This is some text</li>
<img src=&quot;graphic.gif&quot;
onmouseover=&quot;changeBGColour('216', '#AAAAFF');&quot;
onmouseout=&quot;changeBGColour('216', '#8888FF');&quot;>



Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top