forked from bitovi/jquerypp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselection.html
More file actions
60 lines (58 loc) · 1.61 KB
/
selection.html
File metadata and controls
60 lines (58 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>selection</title>
<style type='text/css'>
body {font-family: verdana}
.error {border: solid 1px red;}
.error_text { color: red; font-size: 10px;}
td {padding: 3px;}
</style>
</head>
<body>
<table id="demo-html">
<tr>
<td> <a href="javascript://" id='textarea'>Select Textarea</a></td>
<td><textarea id='textarea'>012
456</textarea></td>
</tr>
<tr>
<td><a href="javascript://"
id='input'>Select Input</a></td>
<td><input text='text' value='0123456789'/></td>
</tr>
<tr>
<td><a href="javascript://"
id='p'>Select Within One Element</a></td>
<td><p id='1'>0123456789</p></td>
</tr>
<tr>
<td><a href="javascript://"
id='multi'>Select Across Multiple Elements</a></td>
<td><div id='2'>012<div>3<span>4</span>5</div></div></td>
</tr>
</table>
<p>Selection width: <span id="selectionwidth">0</span></p>
<script type='text/javascript' src='../../node_modules/steal/steal.js' main='@empty'></script>
<script type='text/javascript'>
steal('jquerypp/dom/selection', function(){
$('#textarea').click(function(){
$('textarea').selection(1,5).mouseup();
});
$('#input').click(function(){
$('input').selection(1,5).mouseup();
});
$('#p').click(function(){
$('#1').selection(1,5).mouseup();
});
$('#multi').click(function(){
$('#2').selection(1,5).mouseup();
});
$('textarea,input,#1,#2').mouseup(function(){
$('#selectionwidth').text($(this).selection().width);
});
});
</script>
</body>
</html>