Error .getAttribute is not a function - Javascript

This is a discussion on Error .getAttribute is not a function - Javascript ; I am using Firefox and he following works fine in a . js file: var target = document.getElementById("myheader").innerHTML; But when I try var targetId = target.getAttribute("id"); or var targetId = target.getAttribute("id").innerHTML; I get this error in Firebug "target.getAttribute is not ...

+ Reply to Thread
Results 1 to 5 of 5

Error .getAttribute is not a function

  1. Default Error .getAttribute is not a function

    I am using Firefox and he following works fine in a .js file:

    var target = document.getElementById("myheader").innerHTML;

    But when I try
    var targetId = target.getAttribute("id"); or
    var targetId = target.getAttribute("id").innerHTML;

    I get this error in Firebug "target.getAttribute is not a function"

    I would be grateful for any assistance.


  2. Default Re: Error .getAttribute is not a function

    On Oct 13, 12:14 pm, Steve <stephen.jo...@googlemail.com> wrote:
    > I am using Firefox and he following works fine in a .js file:
    >
    > var target = document.getElementById("myheader").innerHTML;
    >


    Leave off the ".innerHTML."

    > But when I try
    > var targetId = target.getAttribute("id"); or


    Strings don't have a getAttribute method. This would fail in any
    browser.


  3. Default Re: Error .getAttribute is not a function

    Steve meinte:
    > I am using Firefox and he following works fine in a .js file:
    >
    > var target = document.getElementById("myheader").innerHTML;


    Returns a string.

    > But when I try
    > var targetId = target.getAttribute("id"); or
    > var targetId = target.getAttribute("id").innerHTML;
    >
    > I get this error in Firebug "target.getAttribute is not a function"


    Strings don't have a getAttribute() method.

    Leave out the "innerHTML".

    Gregor


    --
    http://www.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://www.licht-blick.at ::: Forum für Multivisionsvorträge
    http://www.image2d.com ::: Bildagentur für den alpinen Raum

  4. Default Re: Error .getAttribute is not a function

    Gregor Kofler wrote:
    > Steve meinte:
    >> But when I try
    >> var targetId = target.getAttribute("id"); or
    >> var targetId = target.getAttribute("id").innerHTML;
    >>
    >> I get this error in Firebug "target.getAttribute is not a function"

    >
    > Strings don't have a getAttribute() method.
    >
    > Leave out the "innerHTML".


    And

    var targetId = target.id;

    suffices.

    http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-58190037


    PointedEars

  5. Default Re: Error .getAttribute is not a function

    Thanks for the help.

    On Oct 13, 8:40 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
    wrote:
    > Gregor Kofler wrote:
    > > Steve meinte:
    > >> But when I try
    > >> var targetId = target.getAttribute("id"); or
    > >> var targetId = target.getAttribute("id").innerHTML;

    >
    > >> I get this error in Firebug "target.getAttribute is not a function"

    >
    > > Strings don't have a getAttribute() method.

    >
    > > Leave out the "innerHTML".

    >
    > And
    >
    > var targetId = target.id;
    >
    > suffices.
    >
    > http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-58190037
    >
    > PointedEars




+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 11-08-2007, 03:40 PM
  2. MySQL function error
    By Application Development in forum PHP
    Replies: 2
    Last Post: 11-08-2007, 08:45 AM
  3. xmldom getAttribute firefox problem
    By Application Development in forum Javascript
    Replies: 3
    Last Post: 10-21-2007, 07:09 PM
  4. sequence function error
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 09-01-2006, 09:23 AM
  5. Function sequence error
    By Application Development in forum ADO DAO RDO RDS
    Replies: 0
    Last Post: 07-31-2006, 02:50 PM