开发者

How do I add another sibling element in e4x?

开发者 https://www.devze.com 2023-01-17 00:09 出处:网络
If I want to create: <foo> <bar>example1开发者_StackOverflow社区</bar> <bar>example2</bar>

If I want to create:

<foo>
  <bar>example1开发者_StackOverflow社区</bar>
  <bar>example2</bar>
</foo>

using e4x, and I already have:

foo.bar = <bar>example1</bar>

How do I add the additional bar tag?


You either write another literal,

foo += <bar>example3</bar> ;

or you use the relevant methods: http://www.ibm.com/developerworks/library/x-javascript4x.html (Table-1),

var addition = <bar>example3</bar>
foo.insertChildAfter(foo.bar[1],addition) ;

HTH

0

精彩评论

暂无评论...
验证码 换一张
取 消