焦点聚焦失焦默认值显示隐藏

Posted jinsuo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了焦点聚焦失焦默认值显示隐藏相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<input type="checkbox" name="">
<input type="checkbox" name="">
<input type="checkbox" name="">
<input type="text" name="" value="请填写...">
    
</body>
<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
<script type="text/javascript">
    $(function(){
        $("input[type=‘checkbox‘]").prop("checked",true);
        $("input[type=‘checkbox‘]:eq(2)").prop("disabled",true);
        $(input[type=text]).focus(function(){
            var mozhi=$(this).val();
            if(mozhi==请填写...){
                $(this).val(‘‘)
            }
        });
        $(input[type=text]).blur(function(){
            var thisval=$(this).val();
            if(thisval==‘‘){
                $(this).val("请填写...");
            }
        })

    })
</script>
</html>

 

以上是关于焦点聚焦失焦默认值显示隐藏的主要内容,如果未能解决你的问题,请参考以下文章