开发者

Mootools - How to append text at the beginning

开发者 https://www.devze.com 2023-03-26 03:16 出处:网络
How to append text at the begin using function appendText? For example: HTML: <div id=\"myEleme开发者_如何学Cnt\">Hey.</div>

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

精彩评论

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