onclick - HTML, . - . , , , " , HTML , .
, :
<button onclick="if(someFunction()) location.href='some_place';"></button>
, , . a href:
<a href="some_place" onclick="return someFunction();"></a>
someFunction false, click , .
, :
onclick="return someOtherFunction()"
someOtherFunction .
JS:
document.getElementById("the_id_of_the_element").onclick=function() {};
( ):
function bindEvent(element, type, handler) {
if(element.addEventListener) {
element.addEventListener(type, handler, false);
} else {
element.attachEvent('on'+type, handler);
}
}
bindEvent(document.getElementById("the_id_of_the_element"), 'click', function() { });
jQuery ,
$("#the_id_of_the_element").on("click", function() {});
$("#the_id_of_the_element").on("click", function() {});