Is there a better way of writing this?
$('<span class="a"></span>').insertAfter($('#email'));
$('<span class="a"&g开发者_运维百科t;</span>').insertAfter($('#username'));
$('<span class="a"></span>').insertAfter($('#password'));
$('<span class="a"></span>').insertAfter($('#password_confirmation'));
insertAfter can take a query string:
$("<span class=\"a\"></span>").insertAfter("#email,#username,#password,#password_confirmation")
$('#email,#username,#password,#password_confirmation')
.insert($('span').attr('class', 'a'));
精彩评论