我试图用这样的jquery在ASP gridview中放大图片。
<style>
.enlargeImg{
width:600px;
height:600px;
}
</style>
<script src="../Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.pageContainer').on('click','img', function () {
$(this).toggleClass('.enlargeImg');
});
});
</script>
我点击图片好了(可以打电话给警报),但是我无法让这些图片工作。是否可以这样做?
答案 0 :(得分:1)
使用toggleClass(.enlargeImg
)时不需要额外的点,只需使用enlargeImg
。
p.s。我缩小了css中图片的大小,使其适合堆栈代码段。
$(document).ready(function() {
$('.pageContainer').on('click', 'img', function() {
$(this).toggleClass('enlargeImg');
});
});
&#13;
.basicImage{
width: 100px;
height: 50px;
}
.enlargeImg {
width: 200px;
height: 150px;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='pageContainer'>
<img src='https://kaggle2.blob.core.windows.net/datasets-images/152/327/43994ab64328703c9e656b04e6769947/dataset-original.jpg' class='basicImage' />
</div>
&#13;