user656925
user656925

Reputation:

setting value of name for an image in the DOM

I need to set the value of name for my image tag in the DOM. What is the correct property name? More importatnly how do I navigate the DOM, i.e. finding all the different properties and methods with out having to post each time I need one? I tried this search on Mozilla Developer

Upvotes: 0

Views: 63

Answers (1)

jfriend00
jfriend00

Reputation: 707786

If, by "name", you mean the title of the image, then it would be the .title attribute on the image.

You navigate the DOM based on what you're trying to find and what identifiers there are in the DOM. You can find things by ID, by class name, by tag type or even by attribute. Which you would use depends upon how your HTML is strucutred, what you're looking for and what identifying information is in the HTML. If you post your HTML and which objects you're trying to locate, we can explain what your options are.

document.getElementById("xxxx") will find any object in the DOM by id. document.getElementsByTagName("xxxx") will find a list of objects by tag name.

For more advanced methods of finding things, people generally use a selector library (such as Sizzle or what's in jQuery or YUI) that contains much more advanced logic.

Upvotes: 1

Related Questions