18

Aug

Easily highlight text when you click a <textarea>

I used this in a project that I just finished and I thought that I’d share.

    $('#badge-code').focus(function(){
        $(this).select();
    });

If the <textarea> element on your page is #badge-code then, using jQuery, the text in that textarea will be highlight when they click on the box.

This is great if you have a lot of code for your badge but not a lot of page real estate.

Remember, everyone hates scrolling page elements.