como adicionamos ou removemos o atributo readonly da caixa de texto ao clicar no botão radion no cakephp usando jquery?

Aqui está o meu HTML gerado pelo cakephpcaixa de rádio ecaixa de texto roteiro:

<input type="radio" id="need_staff_on_site" name="data[CaterRequest][need_staff_on_site]" value="yes" class="staff_on_site"><span>Yes</span>

<input type="radio" id="need_staff_on_site" name="data[CaterRequest][need_staff_on_site]" class="staff_on_site" value="no"><span>No</span>

How many staff?<input type="text" maxlength="3" id="no_of_staff" name="data[CaterRequest][staff_needed]" class="txtboxSml2" readonly="readonly">

jquery Script:

$(document).ready(function(){
   $('.staff_on_site').click(function(){
   $arr=$(this).val();
   if($arr == "yes"){ $("#no_of_staff").removeAttr("readonly"); }
   if($arr == "no"){ $("#no_of_staff").attr("readonly", "readonly"); }
  });
});

Demonstração jsfiddle Link

questionAnswers(2)

yourAnswerToTheQuestion