比如鼠标现在在AAA;在AAA;上时,鼠标指针本来是那种像大写 I 这种的要输入的指针,但是现在要判断这个字符串是否有分号结尾,如有的话,那么鼠标点击到这个字符串时,变为那个全选的图标,应该是默认。求解。
JavaScript
鼠标
指针
------解决方案--------------------
<textarea rows="6" id="txtBox" cols="60" onclick ="ShowFos()">
AAAAAAAAAAAAAA;BBBBBBBBBBBBBBBBBBBBBBBBBBBB;CCCCCCCCCCCCCCCCCCCCCCCCCCC;DDDDDDDDDDDDDDDDDDDDDDDDDD;
</textarea>
<script type="text/javascript">
function ShowFos() {
var obj = document.getElementById("txtBox");
var val = document.getElementById("txtBox").value;
var t1 = val.substr(0, getCursorPosition(obj).start);
var t2 = val.substr(getCursorPosition(obj).start, val.length);
var start = t1.length - (t1.length - t1.lastIndexOf(";"));
end = t1.length + t2.indexOf(";");
if (end > 0) {
obj.style.cursor = "pointer";
if (obj.setSelectionRange) {
obj.setSelectionRange(start,end);
} else {
var range = obj.createTextRange();