Results 1 to 3 of 3

Thread: JavaScript & Current (dx)html tag

  1. #1
    Join Date
    Nov 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JavaScript & Current (dx)html tag

    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)

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there Acey99,

    have a look at this example, it may give you some ideas...
    Code:
    <!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

  3. #3
    Join Date
    Nov 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Cool.

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •