1) I think it's a good way. $("#some").after("yourhtml"); to insert some tags after...
2) you could save "form#question-setup fieldset:last" for example...so var f = $("form#question-setup fieldset:last"); f.after("...").slideDown("fast").filter("input[type=text]").focus(); f.filter("div.question-remove").click(handler); But you know the code, the children, etc... :) 3) I don't know ... I use children() often...but it depends on the cases On Sep 22, 1:46 am, scottyreg <[EMAIL PROTECTED]> wrote: > Just started with jQuery, absolutely loving it so far! I just have a > few questions about what I have written, and if there are better ways > of doing things (it all works perfectly). > > I copied the relevant code to a text file, which can be seen > athttp://www.doheth.co.uk/files/jqueryhelp.txt > It's a fairly simple script for my PHP Contest Scoreboard program that > allows the user to add a new "question" to a form. Essentially it just > adds a fieldset after the current last one in the form. It also > animates the new fieldset into view, focuses the text field inside it > and adds a button to remove that fieldset. > > My questions are as follows... > > 1. In the 'after' function I have a long string of HTML. This seems > akin to using innerHTML, which is generally frowned upon. Is there a > 'proper' or preferred way to insert HTML in jQuery? > > 2. I have a bit of repeated code here, namely the 'form#question-setup > fieldset:last' selections. The last three groups are referring to the > same fieldset (the newly created one - but this is different from the > one referred to in the first half of the script). Is there some > shortcut I can apply to save a little time and code? (It's probably > negligible, but still...) > > 3. If anyone has any other improvement suggestions, I'm all ears ;) > > -- > Scott.