-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
36 lines (33 loc) · 1.26 KB
/
demo.html
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
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" charset="utf-8"></script>
<script src="jQuery.selectableText.js" charset="utf-8"></script>
<script>
$(function(){
$('textarea, input[type="text"]').selectableText();
var taFrom = $('textarea'),
inpFrom = $('input[type="text"]'),
taTo = $('#ta'),
inpTo = $('#inp');
$('input[type="button"]').click(function(){
taTo.html('['+taFrom.selectableText('getStart')+'; '+taFrom.selectableText('getEnd')+'] - '+taFrom.selectableText('getSelectedText'));
var pos = inpFrom.selectableText('getPos');
inpTo.html('['+pos.start+'; '+pos.end+'] - '+inpFrom.selectableText('getSelectedText'));
});
});
</script>
</head>
<body>
<table border="1">
<tr>
<td><textarea name="" style="width: 200px; height: 100px">текст, который можно (и нужно) выделять мышкой</textarea></td>
<td><span id="ta"></span></td>
</tr>
<tr>
<td><input name="" type="text" value="текст, который можно (и нужно) выделять мышкой" style="width: 200px" /></td>
<td><span id="inp"></span></td>
</tr>
</table>
<input type="button" value="Get" />
</body>
</html>