You could use the jQuery before()
method
peirix
2009-09-04 05:55:52
appendTo()
adds things to the end of that element.
I think you want prependTo()
.
You can chain it together as a single string and use jQuery's before method to insert the HTML before the .addChoice
element:
$('.addChoice').live('click', function(){
var length=$('.fieldChoices input').length + 1;
$(this).before(
'<input id="Choice' + length + '" maxlength="150" value="option' + length + '" />' +
'<div class="seperator" />' +
'<p class="deleteChoice' + length + ' cutsom_button"><a href="#" class="btn lbOn deletechoice"><span class="button_image"><span class="background_16 user_reply">Delete</span></span></a></p>' +
'<div class="seperator" />'
);
return false;
});