I have a script which needs to get the ID of an element on mouseover and then write this id in a popup div.
I’ve got no idea how to go about getting the id of the element.
Can anyone help pelase.
[code]
<script type=”text/javascript”>
$title = “Default Title”;
function getContent()
{
// Get id if element which is hovered over and show title – How do you do this
$content = $title;
return $content;
}
function addContent()
{
getContent(); // call getContent() function to get the content to be added to the popup
var e = document.getElementById(“popup”);
if(e) e.innerHTML = $content; // Add content to popup div
}
function removeContent()
{
var e = document.getElementById(“popup”);
if(e) e.innerHTML = “”; // Remove content from popup div
}
</script>
<div id=”Title One” class=”leaf1″ onmouseover=”addContent();” onmouseout=”removeContent()”></div><br />
<div id=”Title Two” class=”leaf2″ onmouseover=”addContent();” onmouseout=”removeContent()”></div><br />
<div id=”Title Three” class=”leaf3″ onmouseover=”addContent();” onmouseout=”removeContent()”></div><br />
<div id=”popup”></div>
Thanks