javascript - Remove text cursor to input with Jquery - Stack Overflow

when I do focus on an input$('#bar input').focus(function(){ code code});in the input app

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
Add a ment  | 

2 Answers 2

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745210686a4616820.html

相关推荐

  • javascript - Remove text cursor to input with Jquery - Stack Overflow

    when I do focus on an input$('#bar input').focus(function(){ code code});in the input app

    9小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信