| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta charset="UTF-8"> |
| 5 |
<title>editable</title> |
| 6 |
</head> |
| 7 |
<body> |
| 8 |
<!-- 1. Define some markup --> |
| 9 |
<button type="button">Select</button> |
| 10 |
<input type="text" value="Lorem ipsum"> |
| 11 |
|
| 12 |
<!-- 2. Include library --> |
| 13 |
<script src="../dist/select.js"></script> |
| 14 |
|
| 15 |
<!-- 3. Select! --> |
| 16 |
<script> |
| 17 |
var input = document.querySelector('input'); |
| 18 |
var button = document.querySelector('button'); |
| 19 |
|
| 20 |
button.addEventListener('click', function(e) { |
| 21 |
var selected = select(input); |
| 22 |
console.log(selected); |
| 23 |
}); |
| 24 |
</script> |
| 25 |
</body> |
| 26 |
</html> |