Home >Web Front-end >HTML Tutorial >Click on the background image_html/css_WEB-ITnose

Click on the background image_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:24:061047browse

Use a small picture as a background. I want to monitor the click event of the small picture. How should I monitor it.
.libiao_menu{ background:url("images/1.gif") no-repeat 0 -41px;}
I just want to monitor the click event of this 1.gif image.


Reply to discussion (solution)

Simulation can be judged by coordinates

Is there no direct judgment? Please be more specific by judging by coordinate simulation, thank you.

Place a transparent label on the image, adjust the size to be the same as the image, and then listen to the click event of this label.

What does background image monitoring mean?
Isn’t it possible to monitor .libiao_menu?
Is there something else in .libiao_menu? Clicking on that will not punish the monitoring?
If this is the case, listen to .libiao_menu, then listen to other content in it, and then stop bubbling

Assume your picture is:

<img src='/test.jpg' id='test'/>

If you are If you use Jquery:
$(document).ready(    function(){        $('#test').click(            function(){                alert('this is a picture');            });});

If you use ordinary JS code:
window.onload=function(){    img1=document.getElementById('test');    img1.click=function(){        alert('This is a picture');    }}

When you click on the picture, a dialog box will appear, prompting This is a picture

$(.libiao_menu).click(function(){
alert('clicked');
});

The answer on the 5th floor

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn