How can I highlight a word in a text component from JavaScript? [For instance, as the result of a spell check.]

Jayesh Nazre

Well you can highlight that using the select() function:


<html>
<head>
<Script language=javascript>
function test() {
document.frm_test.txt_value.select();

}

</script>
</head>
<body>
<form name=frm_test id=frm_test>
<input type=test value=Hi name=txt_value id=txt_value>
<input type=button onclick="test()" value=Highlight>
</form>

</body>
</html>
Note:
If you need to highlight only specific text in a text box then that's not possible. For example, if the text box contains "hi there", then you cannot highlight "there" only. The entire text "hi there" will get highlighted.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact