Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
-7
rated 0 times [  0] [ 7]  / answers: 1 / hits: 44051  / 14 Years ago, tue, october 5, 2010, 12:00:00

I have following a tags:



<a href=#tab1>Any tab1 Label</a>
<a href=#tab2>tab2 Label</a>
<a href=#tab3>Any tab3 Label</a>
<script>
function tellMyName()
{
alert(this.href);
}

</script>


Now i want to bind the tellMyName function to all the a tags and get tab1 if Any tab1 Label is clicked, tab2 if tab2 Label is clicked and so on...


More From » jquery

 Answers
3
function tellMyName() {
alert(this.hash.substr(1));
}

$('a').click(tellMyName);

[#95419] Friday, October 1, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dylondaytond

Total Points: 92
Total Questions: 88
Total Answers: 96

Location: China
Member since Fri, Jan 15, 2021
3 Years ago
dylondaytond questions
Tue, Jun 22, 21, 00:00, 3 Years ago
Thu, May 7, 20, 00:00, 4 Years ago
;