using jquery to get dom elements name
Is there a way to retrieve a elements name as a string that is also cross browser compatible.
for example I have an event that I look at the target and I want to just get the name of it. So for example I click on a a tag and the eventListener returns the event.
myEventListener: function(event){
strName = event.target
}
The above gives me the target but what I want is just a value of the name of the a tag. so an a tag would give me a string result of "a" so something like this pseudo code.
myEvent开发者_C百科Listener: function(event){
strName = event.target.name
}
Your pseudocode should work just fine! A name
property is exposed on a
elements.
You can get the name by using
$(event.target).attr("name")
精彩评论