Write Following Codes to get the position of cursor in text box
<!doctype>
<html>
<head>
<script type="text/javascript">
function getPos()
{
var input = document.getElementById("txt");
if (!input) return; // No (input) element found
if (document.selection) {
// IE
input.focus();
}
alert(('selectionStart' in input ? input.selectionStart:'' || Math.abs(document.selection.createRange().moveStart('character', -input.value.length))));
}
</script>
</head>
<input type="text" id="txt"/>
<button onclick=" getPos();">Find</button>
</html>
Demo:-
No comments:
Post a Comment