fastest way is to use the .is()
jQuery function.
if ( $('input').is('[readonly]') ) { }
using [readonly]
as a selector simply checks if the attribute is defined on your element. if you want to check for a value, you can use something like this instead:
if ( $('input').is('[readonly="somevalue"]') ) { }