<html>
<body>
<script language="JavaScript">
function function1() {
var myText = document.selection.createRange();
if (myText.queryCommandEnabled("Delete") == true) {
document.execCommand("Delete");
}
}
</script>
<p id="myText">Sample text to be selected and deleted.</p>
<input type="button" value="Delete selection" onclick="function1();">
</body>
</html>
|