Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Friday, May 18, 2012
add "readonly' to <input > (jQuery)
How can i add "readonly" to a specific <input > ? .attr('readonly') does not work.
$('#inputId').attr('readonly', true);
ReplyDelete.attr('readonly', 'readonly') should do the trick. Your .attr('readonly') only returns the value, it doesn't set one.
ReplyDeleteI think "disabled" excludes the input from being sent on the POST
ReplyDeleteYou can disable the readonly by using the .removeAttr;
ReplyDelete$('#descrip').removeAttr('readonly');
For enabling readonly:
ReplyDelete$("#descrip").attr("readonly","true");
For disabling readonly
$("#descrip").attr("readonly","");