when I do focus on an input
$('#bar input').focus(function(){
// code code
});
in the input appears the text cursor... and the only way to remove it (so like the input it not focus) is to click in another part of document...
with jquery how i can remove the text cursor ?
i tried this:
$('#bar input').off('focus');
but this remove listener not text cursor
thanks!
when I do focus on an input
$('#bar input').focus(function(){
// code code
});
in the input appears the text cursor... and the only way to remove it (so like the input it not focus) is to click in another part of document...
with jquery how i can remove the text cursor ?
i tried this:
$('#bar input').off('focus');
but this remove listener not text cursor
thanks!
Share Improve this question asked Nov 28, 2015 at 18:50 BorjaBorja 3,5797 gold badges38 silver badges75 bronze badges 1- 2 Should the user still be able to type when removing the cursor? – Jacques Marais Commented Nov 28, 2015 at 18:55
2 Answers
Reset to default 2$('#bar input').on('focus', function(e) {
e.preventDefault();
$(this).blur();
}
This code disables the focus. But it's better if you make a disabled input.
<input disabled="disabled" type="text">
You can do it easily with css like the code below.
#bar input{
color : transparent;
text-shadow : 0 0 0 #000;
}
#bar input:focus{
outline : none;
}
<div id="bar">
<input type="text"/>
</div>
Hope this will help you.