f6056

3-3 编程练习:jQuery键盘事件案例

3-3 编程练习

完善下面的代码,在input框中输入内容的时候同样显示在下面的p标签中

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>习题</title>
</head>

<body>
    <input type="text" value="">
    <p></p>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
    <script>
    //此处写代码
    </script>
</body>

</html>

 

任务

1、选中input元素

2、使用键盘事件,将input框中的内容添加到p标签中

任务提示

val()方法返回或者设置被选元素的值,获取输入框中的内容可以使用val()

参考代码

$($).ready(function () {
    $(\'input\').keyup(function () {
        $(\'p\').text($(\'input\').val());
    })
})
View Code

 

分类:

技术点:

相关文章:

  • 2021-11-17
  • 2021-12-09
  • 2021-05-27
  • 2022-02-03
  • 2021-05-13
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-02-07
  • 2021-12-09
  • 2021-12-09
  • 2021-12-02
相关资源
相似解决方案