I am trying to navigate to another page using jquery
Markup :
<input type="image" name="ImageButton1" id="btnCancel" src="../images/btn_cancel.gif" />
JS
$('input[type="image"][id^="btnCancel"]').live('click', function () {
window.location.replace('default.aspx');
});
Page just refreshes, it does not navigate to desired page. when i change type=button
it works.
How to achieve the same by keeping type as image only ?
$("#btnCancel").on('click', function () {
window.location.href = 'default.aspx';
});
Use preventdefault:
$('input#btnCancel').on('click', function (e) {
e.preventDefault();
window.location.replace('default.aspx');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With