javascript - Handling clicks outside an element without jquery -


i implement solution this

how detect click outside element?

but i'm using javascript library $() function defined

any suggestions?

this easy accomplish. shame load jquery library 1 feature.

if other library you're using handles event binding, same thing in library. since didn't indicate other library is, here's native solution:

example: http://jsfiddle.net/patrick_dw/wwkjr/1/

window.onload = function() {      // clicks inside element     document.getelementbyid('myelement').onclick = function(e) {             // make sure event doesn't bubble element         if (e) { e.stoppropagation(); }          else { window.event.cancelbubble = true; }             // place code element here         alert('this click inside');     };      // clicks elsewhere on page     document.onclick = function() {         alert('this click outside');     }; }; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -