我不确定这是否正确$('#bigImage').attr("data-big", LargeImagePath);但是同样的声明可以正常工作'src'.
IE浏览器.在JSP上我得到的值mediumImagePath但不大可能.attr不会使用,data-big所以我应该使用什么data-big.
xyz.js
function getImageDetails(mediumImagePath, LargeImagePath) {
alert(mediumImagePath+"_______"+mediumImagePath);
jQuery.ajax({
type : 'GET',
url : 'productDetailsPage.do',
data : {},
success : function(data) {
$('#bigImage').attr("src", mediumImagePath);
$('#bigImage').attr("data-big", LargeImagePath);
alert(data);
$("#productListPage").hide();
$("#productDetailsPage").show();
}
});
}
Run Code Online (Sandbox Code Playgroud)
这是div我试图设置这些值的地方:
Abc.Jsp
<div class="view-product">
<img id="bigImage" class="fancybox" src=""
data-big="images/home/suitlarge.jpg" />
<h3>ZOOM</h3>
</div>
Run Code Online (Sandbox Code Playgroud)
Productdiv.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div>
<c:forEach items="${products}" var="products">
<div class="col-sm-4">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<img src="${products.smallImage}" onclick="getImageDetails('${products.mediumImage}', '${products.largeImage}');" alt="${products.productId}productImage" />
<h2>${products.allPrice}</h2>
<p>${products.name}</p>
</div>
</div>
<ul class="nav nav-pills nav-justified">
<li><a href=""><i class="fa fa-plus-square"></i>Add to
Wishlist</a></li>
</ul>
</div>
</div>
</c:forEach>
</div>
Run Code Online (Sandbox Code Playgroud)
请帮忙解释一下是什么问题.
当您想访问该data属性时,您应该使用data而不是attr
所以你的代码应该是这样的$('#bigImage').data("big", LargeImagePath);
这是一个完整的示例:
<head runat="server">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var big = $("#bigImage").data("big");
alert(big);
});
</script>
</head>
<body>
<img id="bigImage" class="fancybox" src="" data-big="images/home/suitlarge.jpg" />
</body>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
102 次 |
| 最近记录: |