I’ve got UserControl with button. I’m trying to catch click event of this button using jQuery.
My code in ascx:
<link type="text/css" href="css/jquery-ui-1.8.22.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.22.custom.min.js"></script>
<script type="text/javascript" src="js/myjQueryCode.js"></script>
<button id="test-button">Test</button>
Code in myjQueryCode.js.
I’ve tried this:
$('#test-button').bind('click', function() {
alert("123");
});
and this:
$("[id$=test-button]")
.button()
.click(function() {
alert("123");
});
and this:
$('#test-button')
.button()
.click(function() {
alert("123");
});
Nothing is work.
It should just be:
Make sure that the code can actually execute. For example, wrap the statement in an executed function like so:
Or execute once the document is ready, like so: