adsense

Friday, October 26, 2012

asp.net text box highlight text on click

Sometimes you might have come across in situations where you need to select all text in the textbox on click. There can be many other ways to do this but here I've used jQuery to achieve this.


<script type='text/javascript'
src='../Scripts/jquery-1.3.2.min.js'>
</script>
<script type="text/javascript">
$(function() {
$('input[id$=txtBoxName]').click(function() {
$(this).focus().select();
});
});

This script  work on all leading browsers.

Cheers
Samitha

No comments:

Post a Comment