<script language="JavaScript">
<!--
//** power by fason
function s(o)
{
z = document.selection.createRange();
if(/<h>$/g.test(o.value))
z.text = '</h>'
}
//-->
</script>
<body>
<textarea onkeyup=s(this)></textarea>
</body>
<!--
//** power by fason
function s(o)
{
z = document.selection.createRange();
if(/<h>$/g.test(o.value))
z.text = '</h>'
}
//-->
</script>
<body>
<textarea onkeyup=s(this)></textarea>
</body>
如果能在自动加上</h>的时候,也能调整光标的位置到<h>和</h>之间就更好了。
小弟在此借光问一下:)
<!--
//** power by fason
function s(o)
{
var str = '</h>';
if(/<h>$/g.test(o.value))
{
with(document.selection.createRange())
{
text = '</h>'
moveStart("character",-str.length);
collapse();
select();
}
}
}
//-->
</script>
<body>
<textarea onkeyup=s(this)></textarea>
</body>