I'm having to work within an environment in which I cannot use additional frameworks.
I am trying to send the id of a dynamically generated td to a function to be processed.
Looks something like this:
'<td id="td' +开发者_运维知识库 j + '" class="r' + i + 'c' + j%2 + '" onclick=GetLocation(this)>'
I'm just not sure (and cannot find after reading articles for an hour or so) how to pass the object's id. Any insight would be appreciated.
My guess is you could do the following in your GetLocation()
function:
var GetLocation = function(someObject){
var objectID = someObject.id;
alert("the id is -> " + objectID);
};
If the id is assigned, you could either pass it as this.id
or just pass this
itself and access the id inside the function body like obj.id
精彩评论