SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: creating an id

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    455
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    creating an id

    How do you create an id for an element?

    I successfully created a paragraph with:

    var newLink = document.createElement('p'); //create paragraph

    and tried (unsuccessfully) to create an id with:

    newlink.setAttribute('id', 'noSug');

    What's the right way?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,253
    Mentioned
    196 Post(s)
    Tagged
    2 Thread(s)
    That's the right way, kinda sorta

    newlink is undefined, try newLink instead.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    455
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mittineague. Sorry it took so long to thanks you. I was out for a couple days.


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
  •