Is there much of a point to using something like:
img.setAttribute("src", "www.mysite.bmp");
vs.
img.src = "www.mysite.bmp";
If there is, why? Is it for private data (if JS has that stuff)? And the samething for getAttribute.
Is there much of a point to using something like:
img.setAttribute("src", "www.mysite.bmp");
vs.
img.src = "www.mysite.bmp";
If there is, why? Is it for private data (if JS has that stuff)? And the samething for getAttribute.
I'd assume that this is useful when the attribute isn't availabe in the object.attribute method.
This might work for a made up attribute, perhaps, if you needed to store an additional property in the tag. I'm not really sure.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Not usually, no.
Keep in mind that the DOM isn't just for the Web, nor is it only for HTML. The DOM can also be used for manipulating XML documents and the short cut property accessors are not defined in this case; using the set/getAttribute methods is the only choice.
When scripting browsers, avoid the method approach. MSIE doesn't implement them properly.
Mike
Bookmarks