Hi,
I have two divs with an Onclick method each, which the only thing that I do is get the name of the clicked div and put the name in a textbox.
The only thing I´d like to do is be able to identify when a click has occured outside of the divs, and on the body, so in the textbox i´d write (“No selection made”).
[CODE]
<div class=”div1″ id=”div1″ onclick=”ObjectClick(this)”>
</div>
<div class=”div2″ id=”div2″ onclick=”ObjectClick(this)”>
</div>
function ObjectClick(object)
{
if(object)
{
object.onmousedown = ObjectClicked(object);
};
}
function ObjectClicked(object)
{
if(object)
{
draggableObject = object;
var selected = document.getElementById(“txtSelectedObject”);
selected.value = “Hi you clicked” + ” ” + object.id;
}
}
I tried adding the onclick event to the body, but this didn´t work,..
Any suggestions for this javascript beginner?
Cheers