How can I choose if I want to append text or html to a div generically?
<p>I'm writing a javascript library and I need to use jquery's append method to add content to a div. I thought that append() treats <code>"straight strings"</code> as text and <code>$("&lt;div&gt;html objects&lt;/div&gt;")</code> as html but apparently if you use <code>append("&lt;p&gt;")</code> then you will get the string parsed into html which means that strings need to be encoded before being appended.</p>

<p>I would like to use something which works like append but which makes distinctions between strings which are to be treated literally and strings which are to be parsed BASED ON THE PARAMETER. Since this is a library I wouldn't like to duplicate all my functions to make text() and html() versions of each.</p>

<p>For example, I want to be able to add the string <code>"&lt;p&gt;xx&lt;/p&gt;"</code> without it being parsed to html but when I want to add the same string as html then I would pass <code>$("&lt;p&gt;xx&lt;/p&gt;")</code> as a parameter instead.</p>

<p>edit: Basically I'm tired of seeing tutorials use append() to append text, because it does not append text, it appends html. I want to know if there is a method which distinguishes appending strings from appending html objects.</p>
