Carat Help! [Javascript]
Posted: Mon Nov 19, 2012 9:38 pm
So, if you notice here on IE, you can insert BBcode by hitting buttons, and not only will it be inserted, but it will move the carat(mouse) to the middle of the tags. Here is my current code, and I am hoping someone here can help me with the carat issue.
Code: Select all
<html>
<head>
<script>
function bold() {
var elem = document.getElementById('post_tags');
elem.value += "<b></b>";
}
function center() {
var elem = document.getElementById('post_tags');
elem.value += "<center></center>";
}
</script>
</head>
<body>
<div id="set_tags" class="advanced_option">
<p>Test:</p>
<input id="post_tags" name="post[tags]" type="text"/>
<input type="submit" onclick="bold()" value="Bold">
<input type="submit" onclick="center()" value="Center">
</div>
</body>
</html>