我有一系列如下所示的文本框,当您单击文本框时,我必须在其中禁用光标并在“X”和“”之间切换其值。这是我写的代码:
HTML 代码:
<input type="text" name="loan1" id="crossCheck1" class="crossCheck" onfocus="this.blur()" readonly="readonly" maxlength='1' style=" width: 13px; height:13px; border-style:none;font-weight:bold; font-family:Arial Narrow; font-size:14px; color:#000000;margin-left:85px;cursor:hand"/>
<input type="text" name="loan2" id="crossCheck2" class="crossCheck" onfocus="this.blur()" readonly="readonly" maxlength='1' style=" width: 13px; height:13px; border-style:none;font-weight:bold; font-family:Arial Narrow; font-size:14px; color:#000000;margin-left:85px;cursor:hand"/>
<input type="text" name="loan3" id="crossCheck3" class="crossCheck" onfocus="this.blur()" readonly="readonly" maxlength='1' style=" width: 13px; height:13px; border-style:none;font-weight:bold; font-family:Arial Narrow; font-size:14px; color:#000000;margin-left:85px;cursor:hand"/>
Javascript:
$(document).ready(function() {
$( ".crossCheck" ).click(function() {
var cross = $('#crossCheck1').val();
var check = 'X' ;
if(cross == "" ){
document.getElementById("crossCheck1").value= check;
}else{
document.getElementById("crossCheck1").value= '';
}
});
});
1. 这里,光标在内容改变的时候是可见的,你能告诉我一种去除光标的方法吗?
2.你能告诉我如何只改变被点击的文本框的值吗?
演示Here
更新:
我不希望文本框中有任何光标,是否可以将其完全删除