[jQuery] Make Readonly input text

[jQuery] Make Readonly input text


Hi, I'm newbie here
there is two input form, checkbox and text. i want if I checked the
chekbox, the input text will become readonly, and if i checked again,
the input text back to normal. I'm trying make this function
function makeReadOnly(a) {
         if ($("a:contains('readonly')")) {
             $("readonly = 'readonly'").replaceWith(" ");
             }
             else {
         $(a).append("readonly = 'readonly'");
             }
         }
but its not working. firebug says that replaceWith is not a function.
anybody can help me out?