How to perform .select() on jQuery masked text input

Posted by dllhell on Stack Overflow See other posts from Stack Overflow or by dllhell
Published on 2012-08-28T15:11:49Z Indexed on 2012/08/28 15:38 UTC
Read the original article Hit count: 100

I'm using http://digitalbush.com/projects/masked-input-plugin/ plugin.

There is an input text with defined mask:

<input type="text" id="txtMyInput" class="FocusSense"/>

and a script:

$(document).ready(function () {
    jQuery(function ($) {            
        $("#txtMyInput").mask("?9.99");            
    });
    $(".FocusSense").focus(function () {
        this.select();
    });
})

As you can see, I would like select all in txtMyInput on focus but but alas! On focus, mask appears and loose .select().

What should I do to preserve mask and .select()?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery