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

<!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>
原文地址:https://www.cnblogs.com/jinsuo/p/7340788.html