PDA

View Full Version : JavaScript & Current (dx)html tag



Acey99
11-13-2006, 06:20 PM
Is there a way to us JS to determine what tag you're over ?
(Similar to colorzilla for the mozilla browsers.)

assume there's a script in place for mouse move (x,y)

coothead
11-13-2006, 06:34 PM
Hi there Acey99,

have a look at this example, it may give you some ideas...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
form {
width:270px;
}
#stuff {
width:500px;
text-align:justify;
margin-top:40px;
}
-->
</style>

<script type="text/javascript">
<!--
function elemId(ev) {
el=(ev.target)?ev.target:ev.srcElement;
if(el.id!='') {
document.getElementsByTagName('textarea')[0].value=
'Your mouse is on the '+el.tagName+'\nit\'s id is "'+el.id+'"';
}
if(el.tagName=='body') {
document.getElementsByTagName('textarea')[0].value='';
}
}
//-->
</script>

</head>
<body onmousemove="elemId(event)">

<form action="#">
<div>
<textarea id="foo" cols="30" rows="5"></textarea>
<input id="blah" type="text"/>
<select id="picker">
<option>selection</option>
<option>Tom</option>
<option>****</option>
<option>Harry</option>
</select>
</div>
</form>

<div id="stuff">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin massa. Nam vehicula.
Morbi velit nisi, mollis id, ultrices luctus, adipiscing sit amet, lectus. Nunc rhoncus
nisl ac enim. Maecenas vestibulum dolor ut velit.
</div>

</body>
</html>
coothead

Acey99
11-13-2006, 06:53 PM
Cool.

Now can you point me in the direction of properties/methods & such for it other r than tagName ?