areyouready344
asked on
how to determine if $(this) is for list_a or list_b?
how to determine if $(this) variable is for list_a or list_b from the following example code? If the $(this) is for list_b, how do I set for list_a at that point in the code?
$('#list_a li') .gt(' + counter +').each(function()
{
if(textWidth < totalWidth)
{
$('#list_b li').append('<li>' + textValue + '</li>')
alert($this).index());
{
});
$('#list_a li') .gt(' + counter +').each(function()
{
if(textWidth < totalWidth)
{
$('#list_b li').append('<li>' + textValue + '</li>')
alert($this).index());
{
});
alert($this).attr("id")); // should alert list_a or list_b
ASKER
thanks leakim
ASKER
leakim, it says undefined.. but $(this).index() works
try this one :
alert( $this).closest("ul").attr( "id") ); // should alert list_a or list_b
alert( $this).closest("ul").attr(
ASKER
Okay I'll give it a try, alert($(this).closest.("ul ").attr("i d"));
ASKER
not working, the alert is not being fired off. alert($(this).closest.("ul ").attr("i d"));
check for a typo error
ASKER
the code works at the first index and then stop without generating the alert,
does this code look correct, alert($(this).closest.("ul ").attr("i d"));
does this code look correct, alert($(this).closest.("ul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wow, my eyes are bad...don't have my glasses on... thanks leakim..
ASKER
it only says, ul_a but how do I get it to say ul_b?
ASKER
oops, i mean the alert only says #list_a, how do i get it to say #list_b
not sure...
$('#list_a li,#list_b li').gt(' + counter +').each(function()
$('#list_a li,#list_b li').gt(' + counter +').each(function()