The key reason your code isn't working is because you're trying to iterate a string, which isn't what you really want to do.
To iterate jQuery collections, try the other form of .each()
:
$("div[data-role=page]").each(function() {
//...
});
$.each()
is (usually) for arrays or plain objects.