I want to disable click on a certain I tried writing onclick=\"retur
You can try this CSS
<style type="text/css" media="print,screen" >
.unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>
<div class="unselectable">
asdasdsadsadsad<br>asdasdasd
</div>
<br><br>
<div>
qqqqqqqqqqqqqqqq<br>asdasdasd
</div>
<div id="div-test-id" style="width:100px;height:100px;background-color:yellow;">Lorem ipsum</div>
<script type="text/javascript">
var div_click_escape=function(eventObject){
return false;
};
$(function(){
$("#div-test-id").click(div_click_escape);
$("#div-test-id").mousedown(div_click_escape);
$("#div-test-id").mouseup(div_click_escape);
}
</script>
Will avoid to select the text.
document.getElementById('div1').onmousedown = new function ("return false");
If you want to disable selection of the text only, use:
<div onselectstart='return false;'>
text
</div>
div{
-moz-user-select: none;-webkit-user-select: none;
-khtml-user-select:none;o-user-select:none;
user-select: none;
}