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>
精彩评论