View Full Version : API DOM Help

17 Apr 2007, 6:08 AM
Is there a method to read non-standard attributes of DOM elements?

17 Apr 2007, 6:56 AM
What is a 'non-standard attribute'. If the Element class doesn't expose a method to do what you want, you can still access the native dom property of the Element object and perform base dom functions. http://extjs.com/deploy/ext/docs/output/Ext.Element.html#dom

17 Apr 2007, 10:01 AM
Thank you for the response. Here is an example. <div id="myDiv" boo="yikes"> I would like to be able to read the boo attribute value of the div element. Prototype provides the readAttribute() method which is a simple wrapper for getAttribute and also helps with handling attributes in IE. I believe that YUI also has similar method YAHOO.util.Attribute.getValue(), but I'm not sure the exact usage. I was just wondering if there were was an ext wrapper.

17 Apr 2007, 10:23 AM

17 Apr 2007, 5:11 PM
This throws the error:

Ext.get("myDiv").getAttribute is not a function
[Break on this error] alert(Ext.get('myDiv').getAttribute('boo'));

17 Apr 2007, 5:26 PM
Element does not have a getAttribute method. Did you try


17 Apr 2007, 5:31 PM
ah... I knew I forgot something.

17 Apr 2007, 5:41 PM
Thank you again, this worked great! Just so I will know where to look next time, is there documentation on this method within either ext's or yui's api refernce?

17 Apr 2007, 5:45 PM
getAttribute is a native DOM method. YUI may have a wrapper around it - you'd have to look at their API doc.