Reputation: 13166
I have a button like this:
<input type="button" name="btn" id="btn" value="Proceed"/>
After all processes and get the expected result, I need to apply some changes on this button.
I know I can do the first goal using the code below:
$('#btn').attr('value','newValue');
But for the second one, I need something like our previous codes in JavaScript as below:
onclick="window.location.href='newPage.htm'";
Help me please.
Upvotes: 3
Views: 15552
Reputation: 891
Try this:
<script type="text/javascript">
$(document).ready(function() {
$("#btn").click(function() {
$('#btn').attr('value', 'newValue');
window.location="newPage.htm";
});
});
</script>
Upvotes: 0
Reputation: 30993
You can do something like this :
$("#btn").val("newValue").click(function(){
document.location = "newPage.htm";
});
Upvotes: 0
Reputation: 337560
Try this:
$("#btn").attr("onclick", "window.location.href='newPage.htm'");
Or better yet, add a click handler:
$("#btn").click(function() {
window.location.assign = 'newPage.htm';
});
Upvotes: 1
Reputation: 49919
something like, if I understand you correctly:
$("#btn").val("newValue").click(function(){
document.location = "newPage.htm";
});
This will set a new value and bind a click handler.
Upvotes: 1