I want to make a selection.
Here is my example:
HTML:
<table class="tg">
<tr>
<td class="structure-left-side structure-left-side-idea">
<h4>List1</h4>
</td>
<td class="structure-serviceinnova-links" rowspan="3">
<p><a class="Link2" href="">Link2</a></p>
<p><a class="Link1 Link2 Link3" href="">Link1 Link2 Link3</a></p>
<p><a class="Link1" href="">Link1</a></p>
<p><a class="Link1 Link3" href="">Link1 Link3</a></p>
<p><a class="Link1 Link2" href="">Link1 Link2</a></p>
<p><a class="Link3 Link2" href="">Link3 Link2</a></p>
<p><a class="Link3" href="">Link3</a></p>
</td>
<td class="structure-project-links" rowspan="3">
</td>
</tr>
<tr>
<td class="structure-left-side structure-left-side-patent">
<h4>List2</h4>
</td>
</tr>
<tr>
<td class="structure-left-side structure-left-side-startup">
<h4>List3</h4>
</td>
</tr>
</table>
JavaScript:
$('.structure-left-side-idea>h4').on('click', function () {
$(this).removeClass('hidden-link');
var self = this;
$('.structure-serviceinnova-links > p > a , .structure-project-links > p > a').each(function () {
if (!$(this).hasClass('Link1')) {
$(this).addClass('hidden-link');
if ($(this).is(':hidden')) {
$(this).removeClass('hidden-link');
}
}
});
});
$('.structure-left-side-patent>h4').on('click', function () {
$(this).removeClass('hidden-link');
var self = this;
$('.structure-serviceinnova-links > p > a , .structure-project-links > p > a').each(function () {
console.log(this);
if (!$(this).hasClass('Link2')) {
$(this).addClass('hidden-link');
if ($(this).is(':hidden')) {
$(this).removeClass('hidden-link');
}
}
});
});
$('.structure-left-side-startup>h4').on('click', function () {
$(this).removeClass('hidden-link');
var self = this;
$('.structure-serviceinnova-links > p > a , .structure-project-links > p > a').each(function () {
console.log(this);
if (!$(this).hasClass('Link3')) {
$(this).addClass('hidden-link');
if ($(this).is(':hidden')) {
$(this).removeClass('hidden-link');
}
}
});
});
http://jsfiddle.net/mw008znx/11/
I'm really wish someone can help me and explain or give some ideas.
I'm not sure if I got the behavior right take a look: FIDDLE
RELEVANT CODE
$('.structure-serviceinnova-links > p > a , .structure-project-links > p > a').each(function () {
if (!$(this).hasClass('Link1')) {
$(this).addClass('hidden-link');
if ($('.Link1:hidden')) {
$('.Link1').removeClass('hidden-link');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.