0
jquery code:
$("#<%=tbExcludeFilter.ClientID%>").focus(function () {
    $("#<%=tbExcludeFilter.ClientID%>").select();
})

asp:
<asp:TextBox ID="tbExcludeFilter" runat="server" CssClass="autosuggestIncluded" PlaceHolder="Search by employee nameor id"></asp:TextBox>

I want the text in the textbox to be selected on single click on the textbox instead of double click.

Tony
  • 13
  • 3

2 Answers2

0

Do you have the javascript wrapped in a $(document).ready? I would think it would look like this rendered for it to work:

$(document).ready(function() {
  $("#tbExcludeFilter").focus(function() {
    $(this).select();
  });
});

This thread has details, too: Select all contents of textbox when it receives focus (JavaScript or jQuery)

Community
  • 1
  • 1
fostermm
  • 26
  • 1
  • 3
  • I tried keeping it inside $(document). But still couldn't y the focus event is not working. – Tony Feb 19 '14 at 21:51
0

Solution That worked for me:

$(document).ready(function(){
     $("#<%=tbExcludeFilter.ClientID%>").focus(function () {
        setTimeout(HighLight(this),10);
        });
        });
            javascript:
            var HighLightText(element){
        setTimeout(element.select(),0); // time out for Chrome and Safari
        }

Thanks

Tony
  • 13
  • 3