Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Select the content of any DOM element you want.
PHP JavaScript Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
css
img
js
scss
.gitignore
.htaccess
LICENSE
README.md
config.rb
index.php

README.md

_select()

284 bytes gzipped _select.min.js

timpietrusky.com/_select

What?

This function extends the native JavaScript select() (which only works on input and textarea) so that it can be used to select the content of every DOM element you want.

It's written in Vanilla JavaScript (284 bytes gzipped), so you can use it in combination with or without any library.

Works with

  • IE 6+
  • any other browser

Forced Focus

  • Aggressive focus for input / textarea:
    Selects the whole content of a text element with one click or touch.

How to

Download _select.min.js and include it into your page / script.

Vanilla JavaScript

var el = document.querySelector('.demo');

el.addEventListener('click', function() {
  _select(this);
});

jQuery

var el = $('.demo');    

el.on('click', function() {
  _select(this);
});

2013 by Tim Pietrusky

Something went wrong with that request. Please try again.