Hello, I found this useful javascript snippet that helps me toggle the background color of an element:
with this...Code:<script type="text/javascript"> function toggleBgColor( elem ) { var style2 = elem.style; style2.backgroundColor = style2.backgroundColor? "":"#FFFF00"; } </script>
the script can only change the bg-color of the current div (the "testing" text), however, I'd like to change the bg-color of a specific div element (for example, the "testing-element").Code:<div onclick="javascript:toggleBgColor( this );">testing</div> <div id="testing-element">change this color</div>
I think I need to add "GetElementbyID" or whatever to the script/code, but I'm not an expert on this field. any help would be greatful.
thanks.



Reply With Quote


Bookmarks