Get an element's styles. Maybe i’m just weird but normally i set the text initially inside whatever HTML tag i’m using, then when needed use jQuery to replace the content of that text with whatever new text. It’s very easy to use and this post shows some example code and has a working example where you can type in some text that will be appended to a div. text() html() append() appendTo() prepend() prependTo() text() We use the text() method to add text and get text from an element. This enables you to do things like: Get an attribute value from an HTML element. In the HTML above, we have two elements: Our div element, which contains a default piece of text. Answer: Use the jQuery prop () and html () Methods. This selected element replaces content with new content. The replaceWith () method here takes a function as its argument and it removes content from the DOM and inserts new content in its place with a single call. Note that We now also have the jQuery UI JavaScript file for functionality, as well as the CSS file for jQuery UI styling (which uses a number of images, also included in the jquery folder). If you’re looking to change the text of an element or to add new elements to the DOM chances are that you’ve come across innerHTML(), but using it may expose you to cross-site scripting (XSS) attacks.Although you can work around it and sanitize the HTML, there are some safer alternatives.. This is jquery example to replace the texts (function() { //This is for replaicing… Because strip_tags() does not actually validate the HTML, partial or broken tags can result in the removal of more text/data than expected. Likewise, I followed suit with two separate functions named getCellTextAt () and getCellContentsAt (). that allows us to insert new content inside an existing element.. '); });