Using jQuery-click through a div to underlying elements:
javascript code
$('.overlay').click(function(e) { var left = $(window).scrollLeft(); var top = $(window).scrollTop();
//hide the overlay for now so the document can find the underlying elements $(this).css('display','none'); //use the current scroll position to deduct from the click position $(document.elementFromPoint(e.pageX-left, e.pageY-top)).click(); //show the overlay again $(this).css('display','block'); });
var clickarray=[]; function getcoo(thatdiv) { thatdiv.find(".link").each(function() { var offset=$(this).offset(); clickarray.unshift([(offset.left), (offset.top), (offset.left+$(this).width()), (offset.top+$(this).height()), ($(this).attr('name')), 1]); }); }
Using array
javascript code
$("body").click(function(event) { event.preventDefault();//if it is a a-tag var x=event.pageX; var y=event.pageY; var job=""; for(var i in clickarray) { if(x>=clickarray[i][0] && x<=clickarray[i][2] && y>=clickarray[i][1] && y<=clickarray[i][3] && clickarray[i][5]==1) { job=clickarray[i][4]; clickarray[i][5]=0;//set to allready clicked break; } } if(job.length>0) { // --do some thing with the job -- } });
Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.