开发者

Mootools - How to append text at the beginning

How to append text at the begin using function appendText?

For example:

HTML:

<div id="myEleme开发者_如何学Cnt">Hey.</div>

JavaScript:

$('myElement').appendText('Howdy. ', 'before');

Expected result: Howdy. Hey.


If you read the documentation I believe you can achieve it using the following:

$('myElement').appendText(' Howdy. ','top');

which produces this

Using 'before' will append the first param immediately before the <div /> tags:

<body>
   Howdy. <div id="myElement">Hey.</div>
</body>

Using 'top' will append the first param immediately after the opening <div> tag:

<body>
  <div id="myElement"> Howdy. Hey.</div>
</body>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜