javascript - Jquery : Same class number on two different links -
i have next function
$('.link1-**number**').click( function() { $(".link2-**number**").hide() });
when click on link1-number want hide link2-number if number same value.
so <a class="link1-1987">link 1</a>
hides <a class="link2-1987">link 2</a>
<a class="link1-1">link 1</a>
hides <a class="link2-1">link 2</a>
<a class="link1-5">link 1</a>
hides <a class="link2-5">link 2</a>
etc
answer edit:
$('a[class^=link1]').click(function(){ var number = this.classname.split('-')[1]; $('a.link2-' + number).hide(); });
demo
note work if:
there 1 classlink1
anchors. that anchor doesn't have more 1 hyphen. javascript jquery
No comments:
Post a Comment