I am trying to use an element class name and call it as a method for my object.
var thisClass=$this.attr('class')
//thisClass = 'call'
obj.thisClass(ID);
My codes don’t work as I wanted to be. Are there anyways to solve this? Thanks a lot!
You can do
This works because functions are objects as well in javascript and are themselves only attributes of their objects. Object properties can be accessed with the . and the [] notation whereas the [] notations is needed for dynamic names or names that are not legal javascript identifiers.