javascript - Similar function as attr() with parameter for callback function -


i have button , input box. when click button, it's suppose make input box readonly, before calling callback function, problem attr() in jquery doesn't have parameter callback function. there jquery function can use same thing have parameter callback function, or there way 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>    

$(function()  {     $('button').click(function()     {         $('input').attr('readonly', 'readonly');         // want here     }); });  

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -