简体   繁体   中英

Remove text cursor to input with Jquery

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!

$('#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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM