Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dojo equivalent to jQuery.text function?

What is the Dojo equivalent to $("...").text("asdf") and $("...").text()?

Also is there a wiki or site that provides dojo equivalents of jQuery functions?

like image 307
Derek Avatar asked Oct 23 '22 03:10

Derek


2 Answers

A similar function in dojo is NodeList.text()

http://dojotoolkit.org/reference-guide/1.7/dojo/NodeList-manipulate.html#text

You can use like below.

dojo.query("#id").text("asdf");
var txt = dojo.query("#id").text();
like image 162
yongsung.yoon Avatar answered Oct 30 '22 19:10

yongsung.yoon


You are looking for the dojo/dom-prop module. If you look at the source, there is special handling for the textContent property if the current browser does not support it.

    if(propName == "textContent" && !has("dom-textContent")) {
        ctr.empty(node);
        node.appendChild(node.ownerDocument.createTextNode(value));
        return node;
    }

Your code would look like the following:

domProp.set(node, "textContent", "hello world!");

or

domProp.get(node, "textContent");
like image 43
Mike Schall Avatar answered Oct 30 '22 21:10

Mike Schall