Pregunta

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!

¿Fue útil?

Solución

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);  
    });

Otros consejos

$("input").click(function() {
    var $that = $(this);
    $("input").each(function() {
       if ($(this) !== $that) {
          $(this).prop("readonly", false);
       }
    });    
});

try

$("input").attr("readonly", "readonly");
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top