Reputation: 1687
I have a button and an input box. When you click the button, it's suppose to make the input box readonly, before calling a callback function, but the problem is that the attr() in jQuery doesn't have a parameter for the callback function. Is there another jQuery function I can use that basically does the same thing but also have a parameter for the callback function, or is there another way to do this? Thank you.
<button> click me </button>
<input type = "text">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type = "text/javascript">
$(function() {
$('button').click(function(){
$('input').attr('readonly', 'readonly');
});
});
</script>
Upvotes: 0
Views: 43
Reputation: 1809
$(function()
{
$('button').click(function()
{
$('input').attr('readonly', 'readonly');
// Do what you want here
});
});
Upvotes: 2