javascript - Add overlay on click, for existing elements -
javascript - Add overlay on click, for existing elements -
i have ultra-basic layout based on ratchet
<div id="view1"> <header class="bar bar-nav" id="header1"> <h1 class="title">my application</h1> </header> <div class="content" id="content1"> <nav class="bar bar-tab" id="nav1"> <a class="tab-item active" href="#" id="navitem1"> <span class="icon icon-home"></span> <span class="tab-label">home</span> </a> <a class="tab-item " href="#" id="navitem2"> <span class="icon icon-info"></span> <span class="tab-label">about</span> </a> </nav> </div> </div>
when user clicks on element (fulfilling criteria, e.g. has id
set), overlay added covering 1 element (not total page 1 , without messing layout at all)
if nested element receives click event, back-most element picked first , if user clicks again, pick next kid fulfilling criteria. (meaning: if user clicks in bottom part of page, view1
picked first. if clicks again, it'll content1
, nav1
, , on...)
this experiment still cannot figure out.
i've tried different solutions (or plugins, e.g. contenthover) none has worked.
any ideas?
update
the shortest way describe issue : want replicate way inspector (chrome/safari) highlights different elements.
fiddle: http://jsfiddle.net/pta2mbcv/
jquery's event.target
should you. view documentation here.
it's not definite answer, i've coded you, can iterate on it. overlay appears when element clicked has id.
jsfidlle
overlay jquery
$(document).on('click', function (event) { var target = $(event.target); if( target.attr('id') ) { target.addclass('overlay'); } });
overlay css
.overlay:before { position: absolute; content:''; top: 0; left: 0; width: 100%; height: 100%; z-index: 100; background: rgba(5, 11, 37, 0.5); }
javascript jquery html css ratchet
Comments
Post a Comment