Include it in your selector (using a multiple/element selector), like this:
$('input[type="text"], textarea').attr('readonly','readonly');
You can test it here, if it's the only thing you're doing, there's no need for a .each(), you can just call .attr() on all matched elements.