删除焦点文本框上的光标

时间:2017-07-13 10:06:45

标签: jquery html

我想在焦点上删除光标形式的文本框。当我单击文本框时它会显示光标。我想在单击文本框后删除光标

jQuery(document).ready(function($) {
 $(function(){
        $('#edit-field-date-value-value-datepicker-popup-0').blur();
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="edit-field-date-value-value-datepicker-popup-0" name="field_date_value[value][date]" value="" size="20" maxlength="30" class="form-text hasDatepicker date-popup-init">

3 个答案:

答案 0 :(得分:1)

这可以完全用CSS完成:

&#13;
&#13;
jQuery(document).ready(function($) {
 $(function(){
        $('#edit-field-date-value-value-datepicker-popup-0').blur();
    });
});
&#13;
#edit-field-date-value-value-datepicker-popup-0{
  color: transparent;
  text-shadow: 0 0 0 gray;
}
#edit-field-date-value-value-datepicker-popup-0:focus {
    outline: none;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="edit-field-date-value-value-datepicker-popup-0" name="field_date_value[value][date]" value="" size="20" maxlength="30" class="form-text hasDatepicker date-popup-init">
&#13;
&#13;
&#13;

答案 1 :(得分:1)

您可以使用color: transparent;隐藏光标,outline: none;摆脱焦点边框。

jQuery(document).ready(function($) {
  $(function() {
    $('#edit-field-date-value-value-datepicker-popup-0').blur();
  });
});
#edit-field-date-value-value-datepicker-popup-0:focus {
  color: transparent;
  //and 
  //outline: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="edit-field-date-value-value-datepicker-popup-0" name="field_date_value[value][date]" value="" size="20" maxlength="30" class="form-text hasDatepicker date-popup-init">

答案 2 :(得分:0)

您可以在焦点上使用cursor:none。

#edit-field-date-value-value-datepicker-popup-0:focus{
    cursor:none;
}