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 at
http://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.

Reply via email to