Started

Selectors

Utilities

Animation

AJAX

CSS

Event

Manipulation

Cookie

String

Attributes

Data

Storage

Miscellaneous

$text

Append text only content for target element.
$text( element, text )
  1. element [object]
    The target element.
  2. text (optional) [string]
    The text content. If do not provide this value, it returns the text content of matched element.

Notes

This function appends text content only, without caring about HTML tag or other dangerous characters.

Example

HTML code
<div id="box_wrap"></div>

<div id="text_wrap">
This is a text wrap for testing.
<p>Hello!</p>
<span>Hello world!</span>
</div>

<div id="message"></div>
<button onclick="start_text()">update content of box_wrap and get content from text_wrap</button>
CSS code
#box_wrap,
#text_wrap {
	width: 500px;
	font-size: 12px;
	background: #eee;
	border: 4px solid #333;
	padding: 10px;
}
JavaScript code
function start_text()
{
	$text($("box_wrap"), '<div class="box_item">box 1</div><div class="box_item">box 2</div><div class="box_item">box 3</div>' );
	$html($("message"), $text($("text_wrap")));
}
Demonstration
This is a text wrap for testing.

Hello!

Hello world!