i'm hoping you can help me out.
I am trying to trigger an event that lowers the opacity on any clicked tag (h1, img, div, etc..), but I only want this event to trigger on tags that are within a containing div.
Example:
<div id="opacity_wrapper">
<div class="row-fluid">
<div class="span12" style="padding-top: 25px;">
<div class="well well-large" style="background-color: #FFF">
<h1> Some Stuff </h1>
<img src="/img/blah.jpg" />
<h2> more stuff </h2>
<div style="background-color: #000">
<a href="#"> some link </a>
<h2> blahblahblah> </h2>
</div>
</div>
</div>
</div>
</div>
<div>
<h6> more stuff </h6>
<h5> more stuff> </h5>
<button> some button </button>
</div>
So, if any of those 'h1', 'img', 'h2', 'div', or 'a' tags are clicked I want it to trigger (and only for the particular h1, img, or h2 tag that was clicked), but I do NOT want it to trigger for any elements not contained within the opacity-wrapper div, like the 'h6', 'h5', or button tags at the bottom.
Is this possible?
This got me the closest, but it does not exclude any elements.
<script>
$(document).ready(function(){
$( window ).click(function ( e ) {
$( e.target ).css({ opacity: 0.5 });
});
});
</script>
If there is some way to do,
If the window.clicked element is a child of #opacity_wrapper" then {
e.target.css opacity 0.5 } else { do nothing }
Then I believe that would work. Any suggestions? Thanks.