to get the div tag id

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sdja
    New Member
    • Aug 2007
    • 6

    to get the div tag id

    i am developing an application in javascript.I have added a mouse event handler for a div tag. I have specified the div tag as
    <div class="xyz" id="abc"> .........</div>

    if 'e' is the mouseevent object, 'e.srcElement' gives the source element. Consider the following piece of code
    var temp = (typeof e.target != "undefined")?e. target:e.srcEle ment;

    temp.className gives the class name as 'xyz'. Is there a function to retrieve the id of the div tag ?(ie) I want to retrive 'abc'

    Thanks in advance for your help.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    just use temp.id ... isn't that working?

    kind regards

    Comment

    • rnd me
      Recognized Expert Contributor
      • Jun 2007
      • 427

      #3
      random tip:

      shorthand for :
      Code:
      var temp = (typeof e.target != "undefined")?e.target:e.srcElement;
      is
      Code:
      var temp =  e.target || e.srcElement

      Comment

      • sdja
        New Member
        • Aug 2007
        • 6

        #4
        Originally posted by gits
        just use temp.id ... isn't that working?

        kind regards
        It is not working.....

        Comment

        Working...