为了账号安全,请及时绑定邮箱和手机立即绑定

怎么在输入后提取输入的内容?

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>表单中文本框的focus和blur事件</title>
        <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
       <scripe src ="http://libs.baidu.com/jquery/1.9.0/jquery.js"n type="text/javascripe">                                </scripe>
       <link href="style.css" rel="stylesheet" type="text/css" />
        
    </head>
    
    <body>
        <h1>表单中文本框的focus和blur事件</h1>
        <input id="txtest" type="text" value="?" />
        <div>
           
        </div>
        
        <script type="text/javascript">
            $(function () {
                $("input")
                .bind("focus", function () {
                    $("div").html("请输入您的姓名!");
                })
               $("input").bind("blur", function () {
                    if ($(this).val().length == 0)
                        {$("div").html("你的名称不能为空!");}
                        else{
                            
                           $("div").html("这里怎么获取我输入的名字")
                        }
                })
            });
        </script>
    </body>
</html>

正在回答

4 回答

好像楼上答案都对

0 回复 有任何疑惑可以回复我~

$("div").html($(this).val()); 

0 回复 有任何疑惑可以回复我~

$("div").html($("#txtest").val()); 

0 回复 有任何疑惑可以回复我~

 最后的输出语句 :  $("div").html($("#txtest").val()); 

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
jQuery基础课程
  • 参与学习       154699    人
  • 解答问题       7289    个

加入课程学习,有效提高前端开发速度

进入课程

怎么在输入后提取输入的内容?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号