سؤال

Just what it says,

Want to have this

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

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

Thanks!

هل كانت مفيدة؟

المحلول

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/

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top