« Back to the index

WA.get, direct access to the content of the nodes, examples


There are 3 methods to access the content of the nodes fetched by the get:
WA.get.text(str) : fill the content of the nodes with the specified text str. The text will be converted to Entities before to assure the text is visible into the node.
WA.get.html(str) : fill the content of the nodes with the specified text str. The text will not be converted so the entities and HTML tags are respected.
WA.get.append(str) : append to the content of the nodes the specified text str. The text will not be converted so the entities and HTML tags are respected

Let's play with some objects:
function test1() { // lets replace a node with text WA.get("#node1").text('new content of node with <b style="color: red;">tags</b> and entities: &%$/#)"$=áéÚíóä*|¬'); // Lest replace a node with HTML WA.get("#node2").html('new content of node with <b style="color: red;">tags and entities</b>: &%$/#)"$=áéÚíóä*|¬'); // lets add some text WA.get("#node3").append(' - new content appended'); // lets add some text to specific nodes on a class WA.get(".cnode2").append(' = and something extra'); }
Show the result
[id=node1 class=cnode1] Node 1 content
[id=node2 class=cnode2] Node 2 content
[id=node3 class=cnode2] Node 3 content
[id=node4 class=cnode1] Node 4 content



« Back to the index