Is there any function for hiding ‘DIV’s or other html elements on right click, some tutorial, script, simple code javascript or jquery. Example: when is click on link or
tag or ‘li’ or ‘Ul’ or ‘a’ with right click to hide this element… How to do that?
UPDATE: Yes, all your solutions is OK but please view this code and why doesn’ work:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script>
$(document).on("mousedown", "div, img, span, a", function () {
if (event.which === 3)
$(this).hide();
});
</script>
<?php
$url = 'http://www.kupime.com/';
$data = file_get_contents($url);
$data = '<head><base href='.$url.' target="_blank" /></head>'.$data;
echo $data;
?>
And when I click nothing happend. WHY?
You can use
event.whichin your mousedown handler to surmise whether the user clicked with the left, or right mouse button.See this answer for more info on
event.whichEDIT
Naturally, if you want to hide elements other than just div, you can comma-delimit them in on’s selector
Or if you want to hide anything that’s right clicked