Jquery 负边距单击不应起作用
我有一个设置为负的顶部边缘(-15px)的图像,它的作品很好。但问题是点击事件。单击仍在图像的正下方(即从浏览器上图像所在的视图向下+15px)工作Jquery 负边距单击不应起作用,jquery,html,css,jquery-mobile,Jquery,Html,Css,Jquery Mobile,我有一个设置为负的顶部边缘(-15px)的图像,它的作品很好。但问题是点击事件。单击仍在图像的正下方(即从浏览器上图像所在的视图向下+15px)工作 <div data-role="page" > <!-- Header --> <div data-role="header" class="listHeader" data-position="fixed" data-tap- toggle="false"> <i
<div data-role="page" >
<!-- Header -->
<div data-role="header" class="listHeader" data-position="fixed" data-tap- toggle="false">
<img src="images/all_lists_normal.png" class="view_list">
<img src="images/x_normal.png" class="x_image">
<div class="titleList">
<p id="page_title" class="label"></p>
</div>
<img id="id_new_products" src="images/add_products_normal.png" class="addNewItemImage_page4">
<img id="id_find_stores" src="images/find_store_normal.png" class="addNewItemImageMargin">
</div> <!-- / header -->
<!-- Content -->
<div data-role="content" class="mainBackground">
some content....
</div>
</div>
.listHeader {
background: url(../images/header_nologo.png) no-repeat 50% 0px;
background-size: 100% 107%;
height: 60px;
}
.view_list {
float: left;
margin-top: 12px;
}
.x_image {
float: right;
margin-right: 15px;
margin-top: 17px;
}
.addNewItemImage_page4 {
min-width: 100%;
margin-top: 9px;
position:relative;
}
.addNewItemImageMargin {
min-width: 100%;
margin-top: -14px; /****************** PROBLEM ***********/
position:relative;
}
.mainBackground {
background: url(../images/background.jpg) no-repeat 50% 0px;
background-size: 100% 100%;
min-height: inherit;
min-width: 100%;
margin-top: -2px;
}
这是一个将操作处理程序放置在img而不是包装div上的示例: 这将是我试图提出的信息,您提供给我们:
显示您的代码。很可能,您没有在图像上单击,而是在图像的包装器
或
上单击。而且,是的,我们需要查看您的代码才能确定;)@添加了ahren代码,您现在可以提供帮助了吗?我创建了一个JSFiddle来说明将操作处理程序放在img而不是包装div上意味着什么。如果您可以发布实际的单击事件处理程序,那么我们就可以评估您所面临的问题到底是什么。否则,我的假设是,只需在图像上使用click处理程序就可以按预期工作。另外,您的HTML标记不是很整洁,我们也无法查看图像,因此我们不知道您在那里想要实现什么。标题的实际屏幕截图也会有所帮助
$("#id_find_stores")
.click(function(){
alert('hi');
});
$(document).ready(function() {
$('#id_new_products').click(function() {
$(this).css({ "border" : "1px solid red" });
});
});