Reputation: 9
I am retrieving images from database and want them to change on on-click event.
on click event :
<script type="text/javascript">
$(document).ready(function () {
$('.chnj').onclick(function () {
$('#rotatetest').toggle();
});
});
</script>
div containing images :
<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>
The onclick should by triggered when glyphicon within span element having class chnj is clicked.
Upvotes: 0
Views: 205
Reputation: 67525
There's no onclick
event in jquery, it should be click
:
$('.chnj').click(function () {
$('#rotatetest').toggle();
});
You could also use event delegation on()
:
$('body').on('click', '.chnj', function () {
$('#rotatetest').toggle();
});
The onclick
could be used as inline event :
<button onclick="myFunction()">Click me</button>
Or in vanilla js :
myElement.onclick=function(){ myScript };
Hope this helps.
Upvotes: 3
Reputation: 1297
In Jquery you need use .click
, and for multiple event you can use on
instead of "onclick"
. because onclick
use in javascript code.
Upvotes: 0