I have a series of text boxes on a page with a custom touch keyboard. The problem is when one clicks the tab on the custom keyboard and goes to the next text box, the text box's gradient does not remove (my class's removeClass('selected') does not function as usual). Even though the cursor moves on. I tried onfocus="myFunction()"
, css input:focus
selector, and js .focus()
/ .focusout()
.
HTML
<div class="container">
<div class="control">
<fieldset class="control-input input-name-noread gradient open-keyboard">
<label>Name</label>
<input type="text" class="from" id="preference-name" autocomplete="off" value="George">
</fieldset>
</div>
<div class="control">
<fieldset class="control-input input-name-noread gradient open-keyboard">
<label>Name</label>
<input type="text" class="from" id="preference-name" autocomplete="off" value="George">
</fieldset>
</div><div class="control">
<fieldset class="control-input input-name-noread gradient open-keyboard">
<label>Name</label>
<input type="text" class="from" id="preference-name" autocomplete="off" value="George">
</fieldset>
</div></div>
JQuery
$(".keyboard-key-return").click(function() {
$(".control-input").addClass('gradient');
});
$(".open-keyboard").click(function() {
$(".keyboard").show();
});
$(".open-keyboard-readonly").click(function() {
$(".keyboard").hide();
});
$(".keyboard-close").click(function() {
$(".control-input").addClass('gradient');
});
$(".control-input").click(function() {
$(this).removeClass('gradient');
});
$(".keyboard-close").click(function(){
$(".from").blur();
})
$(".keyboard-key-return").click(function(){
$(".from").blur();
})
$(".control-input").focusout(function(){
$(".from").css({
"background-image": "-webkit-linear-gradient(top, rgb(239, 239, 239), rgb(220, 220, 220))"
});
});
$(".control-input").focusout(function(){
$(this).addClass('gradient');
});
css
.from {
width: 443px;
background-color: transparent;
border: none;
height: 68px;;
outline: none;
font-size: 28px;
margin: 5px 0px 0px 0px;
input:focus{
background-image: none;
}
}
Is there an alternative to these methods to detect where the cursor is or a way to detect the focus event so I can remove the class on tab?