Hello all, I'm new to jQuery as we are transitioning away from
Prototype.

Basically we have code like this in the HTML.

<div id="blah" class="blah" onclick="someFunction({src:this,
something:else})>Click me</div>

in our javascript:

function someFunction(params){
   var obj = params["src"];
   ....
   alert(obj.id)
}


What happens is, if I include the jQuery library, all properties/
attributes become undefined using the traditional method.  So even
"obj.className" is undefined.

All examples I've seen thus far use

$("#blah).attr("class") to retrieve the class or other like
attributes.  However since I don't know the id or the class of the
object being passed in, I cannot use jQuery to manipulate the
attributes as I need to.

Things that don't work:

obj.attr("id")  -->  undefined
$(obj).attr("id") --> undefined
$("#blah").attr("id") --> "blah"...but that doesn't help me because I
don't know the id ahead of time

Can someone point me in the right direction?
We would like not to have to go into every HTML page and change the
way the function is called, meaning I know we can get around this if
in the onclick method I pass in the id of the element being clicked on
instead of the keyword "this", but that wouldn't be feasible to change
all the pages in the project at this point.

Thanks,
Shao

Reply via email to