jazzIIIlove
asked on
grabbing a href in query.
hi there;
I have a problem as grabbing the active tab to do some operations.
I have 3 tabs which are practically links
<a href="#tabs-0">My rolls</a>
<a href="#tabs-1">Your balls</a>
<a href="#tabs-2">His arms</a>
what i need is to find out active link (clicked link). I already wrote a click function but failed to differentiate the hrefs as i will need to populate my tab with the clicked tab/link.
Any fast short cut?
Regards.
I have a problem as grabbing the active tab to do some operations.
I have 3 tabs which are practically links
<a href="#tabs-0">My rolls</a>
<a href="#tabs-1">Your balls</a>
<a href="#tabs-2">His arms</a>
what i need is to find out active link (clicked link). I already wrote a click function but failed to differentiate the hrefs as i will need to populate my tab with the clicked tab/link.
Any fast short cut?
Regards.
ASKER
Hi;
Yours is working perfectly but i couldn't adapt it properly to mine..
The issue is that when a li gets active(a tab selected, its class adds the value ui-state-active to its li as above.
I reached the relevant tab; <a href="#tabs-1"> by appending an index tabs-index but couldn't find clicked so that i can populate that tab.
regards.
Yours is working perfectly but i couldn't adapt it properly to mine..
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active">
<a href="#tabs-0">My balls</a></li>
<li class="ui-state-default ui-corner-top">
<a href="#tabs-1">Your balls</a></li>
The issue is that when a li gets active(a tab selected, its class adds the value ui-state-active to its li as above.
I reached the relevant tab; <a href="#tabs-1"> by appending an index tabs-index but couldn't find clicked so that i can populate that tab.
regards.
could you set a test page at jsfiddle?
ASKER
ah, i used your other solution (since you are versatile in your solutions) and works fine for now.
One irrelevant question. you know, in the other question, it was the div who is parent and my question is that does this propogate to children (this <a href is a child) just as that?
regards.
One irrelevant question. you know, in the other question, it was the div who is parent and my question is that does this propogate to children (this <a href is a child) just as that?
regards.
no the event propagate from child to parent
but initialy you bind the click event to the <a href
but initialy you bind the click event to the <a href
ASKER
Ok things got messy and i Also added ids to code which is now:
<a id='tabs-0' href...>
There are my parent lis for each href just above, and append a class to my li like active as follows:
<li class="c1 c2 c3 iamfucked" so iamfucked appears class only when i click that tab and i need that lis child href value.
I went for if($("li").hasClass("iamfu cked))..bu t cannot get the matching href with find()...
Sorry for this question..
Thanks.
<a id='tabs-0' href...>
There are my parent lis for each href just above, and append a class to my li like active as follows:
<li class="c1 c2 c3 iamfucked" so iamfucked appears class only when i click that tab and i need that lis child href value.
I went for if($("li").hasClass("iamfu
Sorry for this question..
Thanks.
to get the href from the li you need to find the link
var href = $("li.iamfucked").find("a" ).attr("hr ef");
var href = $("li.iamfucked").find("a"
ASKER
i tried but i cannot grab the value...
I also tried...
var href = $("li.c1c2.c3.iamfucked"). find("a"). attr("href ");
I also think the if check which is to find the li is working but maybe it is not finding the li (the parent of href):
if($("li").has("c1.c2.c3.i amfucked") )
{
var href = $("li.c1c2.c3.iamfucked"). find("a"). attr("href ");
if i go for hasClass it is false so i used has so that may be the problem.
Regards.
I also tried...
var href = $("li.c1c2.c3.iamfucked").
I also think the if check which is to find the li is working but maybe it is not finding the li (the parent of href):
if($("li").has("c1.c2.c3.i
{
var href = $("li.c1c2.c3.iamfucked").
if i go for hasClass it is false so i used has so that may be the problem.
Regards.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
I find out that i grab the click event before rendering the page..
It works in chrome but not as console.log
I have to think upon it.
I find out that i grab the click event before rendering the page..
It works in chrome but not as console.log
I have to think upon it.
ASKER
Leakim is a life savior :)
Open in new window