Its really sometimes we need to call two functions, first we user click on specified element and another when user clicked on not specified element,
Eg: you have a textbox and control panel div of text box, but you want to call a function to show control div of textbox when user clicked on specified text box but you also want to hide it when user clicked on not textbox.
something like in #jQuery
[javascript]
$("not:abc").click(function (){
//not working…
})
[/javascript]
I have wrote a solution for that, copy to use in your projects
[javascript]
//i prefer to use J instead $ or jQuery;
var j = jQuery;
j(document).ready(function () {
var is_specified_clicked;
j(".specified_element").click(function () {
is_specified_clicked = true;
setTimeout(function () {
is_specified_clicked = false;
}, 200);
})
j("*").click(function () {
if (is_specified_clicked == true) {
//WRITE CODE HERE FOR CLICKED ON OTHER ELEMENTS
j(".event_result").text("you were clicked on specified element");
} else {
//WRITE CODE HERE FOR SPECIFIED ELEMENT CLICKED
j(".event_result").text("you were clicked not on specified element");
}
})
})
[/javascript]