In Google Closure how can I get a property from a DOM element?

試著忘記壹切 提交于 2019-12-08 03:31:03

问题


I can set elements with setProperties, but there does not seem to be a getProperties to get an attribute value. Can anyone help?


回答1:


If you just want to return the attribute value use raw javascript method getAttribute(att_name).

Or if you get an attribute node by name from the current element use getAttributeNode(att_name)

var elem = goog.dom.getElement(element);
var attr = elem.getAttribute('name');
var attrNode = elem.getAttributeNode('name');


来源:https://stackoverflow.com/questions/17592626/in-google-closure-how-can-i-get-a-property-from-a-dom-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!