Computer Science Canada

Jquery, getting more than one id in a function

Author:  nonamedude [ Mon May 16, 2011 10:13 am ]
Post subject:  Jquery, getting more than one id in a function

Hey guys, I seemed to have run into a roadblock.

When I am in a function, is it possible to get more that one id. Here is the code I have right now

code:
$('a.commentUp').bind('click',function()
                {
                    var myid = $(this).attr('id');     //first call
 var myid2 = $('a.common').attr('id2'); //second call   
}


When I do the second call I get an undefined value if I print it out. The first value is fine.

This is what I am trying to get the value of

code:
<a id = $storyID class = 'common'>


This is what the value that works (the first call)

code:
<a id = $commentNumber class = 'commentUp'>

Author:  Zren [ Mon May 16, 2011 11:08 am ]
Post subject:  RE:Jquery, getting more than one id in a function

Look at the difference between these two very carefully.
.attr('id2')
<a id = $storyID

And remember the markup is as follows:
<tag attribute=value attribute=value>

The .attr() function returns the value of the attribute entered as a parameter.

Author:  nonamedude [ Thu May 19, 2011 5:14 pm ]
Post subject:  Re: Jquery, getting more than one id in a function

Oh thanks, i see my mistake


: