0

if clicking something else, the last input (which was clicked) should be readonly -> true again.

here is my code:

<script>
  $(document).ready(function() {

   $("input").prop("readonly", true);      

   $("input").click(function() { 
        $(this).prop("readonly", false); 
    });

  });
</script>

thanks!

Mike
  • 163
  • 1
  • 4
  • 19
  • Erm.... did you already ask the same or its me: http://stackoverflow.com/questions/18485231/jquery-input-prob-disable-false-by-clicking-the-input – Alvaro Aug 28 '13 at 11:05
  • @Alvaro no - now i need help by clicking somewhere else after clicking into the input field – Mike Aug 28 '13 at 11:08

3 Answers3

1

try this

--to make input editable on click
    $('input').bind('click', function () {
        $(this).prop("readonly", false);
    });

--to make input readonly on lost focus
    $('input').bind('blur', function () {
        $(this).prop("readonly", true);  
    });
Amin
  • 294
  • 2
  • 4
  • great job - thanks - but still not working on iOS [link](http://stackoverflow.com/questions/18486676/jquery-code-does-not-work-on-ios) – Mike Aug 28 '13 at 11:43
0
$("input").click(function() {
    var $that = $(this);
    $("input").each(function() {
       if ($(this) !== $that) {
          $(this).prop("readonly", false);
       }
    });    
});
Arvind Bhardwaj
  • 5,078
  • 5
  • 30
  • 48
0

try

$("input").attr("readonly", "readonly");
Liam Allan
  • 1,109
  • 1
  • 7
  • 12