I want to throw an alert when an input has a \'readonly\' attribute. I have tried this:
if($(\'input\').attr(\'readonly\') == \'readonly\'){
alert(\"foo\"
Check the current value of your "readonly" attribute, if it's "false" (a string) or empty (undefined or "") then it's not readonly.
$('input').each(function() {
var readonly = $(this).attr("readonly");
if(readonly && readonly.toLowerCase()!=='false') { // this is readonly
alert('this is a read only field');
}
});