I want to throw an alert when an input has a \'readonly\' attribute. I have tried this:
if($(\'input\').attr(\'readonly\') == \'readonly\'){ alert(\"foo\"
You can just use the attribute selector and then test the length:
$('input[readonly]').length == 0 // --> ok $('input[readonly]').length > 0 // --> not ok