按Backspace键删除图像

时间:2017-03-01 12:30:17

标签: javascript html html5 validation inputbox

在这里,我在输入框中验证答案.i.e。当我输入正确的答案时,对于错误的图像也会出现相应的刻度图像。 在这种情况下,当我按下退格键时,图像需要消失。

我的HTML代码是:

<div class="arithmetic-rw addition-rw" id="addition1" style="position:absolute; left:330px;top:220px; text-align:center; font-size:30px; font-family:arial;">
    <input id="textvisible1" type="text" value="" style="font-size:27px;text-align:center; padding-top:25px; border:0px; position:absolute; left:0px; height:50px; width:150px;" maxlength="4" onblur="javascript:checktxt('texthidden1','texthidden1a','textvisible1','wrong1','correct1');" />
    <div class="correct1"  style="position:absolute;margin-left: 160px; margin-top: 20px; float:right; display: none; "><img src="../images/smallgreen.png"/></div>
    <div class="wrong1" style="position:absolute;margin-left: 160px; margin-top: 20px; float:right; display: none; "><img src="../images/smallwrong.png"/></div>
    <input id="texthidden1" type="hidden" value="413"/>
    <input id="texthidden1a" type="hidden" value="410"/>
</div>

我的JS代码是:

function remove(ah,aha,av,aw,ac) {
    var ath=$("#"+ah).val();
    var ath1=$("#"+aha).val();
    var atv=$("#"+av).val();
    if(atv.toLowerCase() || ath.toLowerCase()) {
        $( "."+ac ).hide();
        $( "."+aw ).hide(); 
    }
}
window.addEventListener("keydown", function(a){
    if(a.keyCode == 8) {
        remove('texthidden1','texthidden1a','textvisible1','wrong1','correct1')
        remove('texthidden2','texthidden2a','textvisible2','wrong2','correct2')
    }
});

0 个答案:

没有答案