【发布时间】:2016-10-23 02:07:27
【问题描述】:
我正在从数据库中检索图像并希望它们在点击事件时更改。
点击事件:
<script type="text/javascript">
$(document).ready(function () {
$('.chnj').onclick(function () {
$('#rotatetest').toggle();
});
});
</script>
包含图像的 div:
<div class="col-md-12" id="rotatetest">
<asp:Repeater ID="rptrTest" runat="server">
<ItemTemplate>
<div class="col-md-9 col-md-push2 test" style="margin-top:50px;">
<img class=" image img-circle" height="200" width="200" src="<%# Eval(" PhotoPath")
%>" style="border:10px solid white;" id="img" />
</div>
</ItemTemplate>
</asp:Repeater>
<div style="margin-top:50px;text-align:left;">
<h3 style="color:white;font-family:Pristina;">
<%# Eval("Description") %>
</h3>
</div>
</div>
当单击具有类 chnj 的 span 元素中的 glyphicon 时,应触发 onclick。
【问题讨论】:
-
能否请您补充更多信息。
-
您的点击方法不是有效的 jQuery 方法,请尝试使用
.on()或.click()。并且从表面上看你的功能,一旦点击触发元素,它所要做的就是切换#rotatetest的可见性 -
我想你会想要使用 click() 而不是 onclick:api.jquery.com/click
标签: javascript jquery html css