I have a parent HTML element with various links, SVG, text inside it at different levels. When a specific link in the parent element is clicked, I try to fade it by 50% and disconnect any further interaction with it from touch / mouse events until it is turned back on.
My code is complex and spaghetti-like, so here is a very simple example:
$(function() { $('.container a').on({
.container { background-color: #123435; padding: 1em; } .info { display: none; background-color: #435123; padding: 1em; } .container a, .info, .info a { color: #bbc; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="container"> <a href="#">Show Info (click me)</a> <br> <a href="thingy1.htm">Other Link 1</a> </div> <div class="info"> Some info (div.container and all it contents now need to be totally disabled) <br> <a href="#">Hide Info</a> <br> </div>
What i tried
When container turns pale, I tried setting disabled attributes for all children, which works for any form input, but not for links.
I also tried adding a “faded” class, and then testing it like this:
$('.container:not(.faded) a').on({ click: function(e) { $('.container').addClass("faded").fadeTo("slow", 0.5); $('.info').fadeTo("slow", 1); } });
.. but it seems that the 'on' action does not account for the new class for the selector .. or something!
Help me please. I am very happy to consider a completely different way to handle this. Thanks.
source share