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

vb.net - How to ignore if a cell is empty nothing -

Sort a complex associative array in PHP -

recursion - Can every recursive algorithm be improved with dynamic programming? -