Jump to content

creating an id SOLVED with thanks in the last post.


niche

Recommended Posts

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?

Edited by niche
Link to comment
Share on other sites

When you created the paragraph, you have newLink as the var name. When you go to set the attribute, you have newlink(L is not cap). Try changing that and see if it works.

  • Like 1
Link to comment
Share on other sites

Lots of good advice. Thank-you for your help Don E, Ingolme, and eTianbun. Sorry it took so long to thank you. I was out for a couple days.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...