Question

Just what it says,

Want to have this

$('input').after(" ");

in YUI, or if not possible in YUI then in pure javascript.

Thanks!

Était-ce utile?

La solution

It's also possible as a one-liner in YUI, if that's what you're using:

Y.all('input').insert(' ','after');

http://jsfiddle.net/h87zP/

Autres conseils

Try following (http://jsfiddle.net/RCUcU/)

var nodes = document.querySelectorAll("input");
var text = "some text";
for (var i = 0; i < nodes.length; i++) {
    var node = nodes[i];
    var textNode = document.createTextNode(text);
    node.parentNode.insertBefore(textNode, node)
}

You will create text node (it isn't html element) https://developer.mozilla.org/en-US/docs/Web/API/document.createTextNode

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top