jQuery textarea append newline behavior

Not sure how you are setting the textarea content, but if you use the jQuery val method, \n works consistently in Firefox and IE (Including IE8): var txt = $(“textarea#idhere”); txt.val( txt.val() + “\nSomething here\n\nAgain”); Causes the textarea to display: Existing content and linebreaks if any. Something here Again You can see a demo here … Read more

What’s more efficient – storing logs in sql database or files?

Logs using files are more efficient, however logs stored in the database are easier to read, even remotely (you can write a web frontend if required, for example). Note however that connecting and inserting rows into the database is error prone (database server down, password wrong, out-of-resources) so where would you log those errors if … Read more

jQuery append() and remove() element

Since this is an open-ended question, I will just give you an idea of how I would go about implementing something like this myself. <span class=”inputname”> Project Images: <a href=”#” class=”add_project_file”> <img src=”images/add_small.gif” border=”0″ /> </a> </span> <ul class=”project_images”> <li><input name=”upload_project_images[]” type=”file” /></li> </ul> Wrapping the file inputs inside li elements allows to easily remove … Read more

How to add a list-item at specific position

You have to use after() instead of append(): Description: Insert content, specified by the parameter, after each element in the set of matched elements. $(‘#list li:eq(1)’).after(‘<li>Position 3</li>’); The documentation of append() clearly says: Insert content (…) to the end of each element. For completeness: Note that :eq(n) matches the nth element of the matching element … Read more