View Full Version : How to determine if onmousedown occur in a specific object

12-17-2007, 04:17 PM
Can you help me with this:

i capture onmousedown for the whole document

onmousedown outside the DIV should hide the DIV
onmousedown in the <DIV id='j_sel'> should do nothing
how can i know that the onmousedown occured in that DIV ?

function hideDIV() {
var o_j = getObj('j_sel');

// ??????
// ??????

o_j.style.display = 'none';
divSet = false;

Cannot figure out this myself, because i am not a real javascript programmer.

12-17-2007, 05:33 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<script language="JavaScript" type="text/javascript">

document.onmousedown=function(event){ MseDown(event) };

function MseDown(){
var zxcevt=window.event||arguments.callee.caller.arguments[0];
var zxcobj=arguments[0]?arguments[0].target:event.srcElement;
if (zxcobj.id&&zxcobj.id=='j_sel') document.getElementById('j_sel').style.visibility='hidden';

<div id='j_sel' style="width:50px;height:50px;background-Color:red;" ></div>