rivkamak
asked on
function who clicked
I have a function set up to run onclick of multiple items.
How can I figure out what was the id of the object that caused the function to run?
How can I figure out what was the id of the object that caused the function to run?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Gary - that's not true. prop() and attr() will give you the correct value, even if you change the ID. The ID is an attribute:
From W3c:
http://www.w3.org/TR/SVGTi ny12/attri buteTable. html
From jQuery Docs:
From W3c:
http://www.w3.org/TR/SVGTi
From jQuery Docs:
Summary of Preferred Usage
The .prop() method should be used for boolean attributes/properties and for properties which do not exist in html (such as window.location). All other attributes (ones you can see in the html) can and should continue to be manipulated with the .attr() method.
attr() will not always give you a dynamic value (tho you are right about the id et al)
Since 1.6.1 using attr() is basically defunct since all it does is call .prop() - so you may as well just use it to start with.
Since 1.6.1 using attr() is basically defunct since all it does is call .prop() - so you may as well just use it to start with.
So I prefer to use prop()