javascript - Click one link disables other in java script -
hello disable other links except clicked 1 after click 1 of links.
here code far:
javascript
$(".link-chart").click(function($e) { if($(this).find(".link-selector-two").hasclass('red')) { $('.link-selector-two', this).addclass('cssclass'); $('.link-selector-one', this).addclass('cssclass'); } else { $('.link-selector-two', this).removeclass('cssclass'); } });
html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a href="#" class="link-chart lx-link-chart"> <div class="link-selector-one"> <div class="link-selector-two red">one</div> </div> </a> <a href="#" class="link-chart lx-link-chart"> <div class="link-selector-one"> <div class="link-selector-two red">two</div> </div> </a>
so idea example if click first link disable second one, if click again first link deselect first link in way working second link available selection again. same option second link if click second disable first one.
any welcome let me know in approach have go.
you this:
js
var $linkchart = $('.link-chart'); $linkchart.click(function(e) { $linkchart.each(function() { if (e.currenttarget !== this) { $(this).toggleclass('disabled'); } }); });
scss
.link-chart { &.disabled { pointer-events: none; opacity: 0.25; } }
here's fiddle show in action. fyi, added third link see it'll work same many links want add.
Comments
Post a Comment