FCC-JS-JQ-Change Text with Click Events-通过点击事件来更改文本

通过点击事件来更改文本。
当我们点击按钮时,我们可以更新HTML页面
任务:点击"Get Message"按钮,将class为message的元素的文本改为:“Here is the message”。
为此在我们的点击事件中加入如下代码:

$(".message").html("Here is the message”);

示例:

<script>
  $(document).ready(function() {
    $("#getMessage").on("click", function(){
      // 请把你的代码写在这条注释以下
      $(".message").html("Here is the message");
      // 请把你的代码写在这条注释以上
    });
  });
</script>


<div class="container-fluid">
  <div class = "row text-center">
    <h2>Cat Photo Finder</h2>
  </div>
  <div class = "row text-center">
    <div class = "col-xs-12 well message">
      The message will go here
    </div>
  </div>
  <div class = "row text-center">
    <div class = "col-xs-12">
      <button id = "getMessage" class = "btn btn-primary">
        Get Message
      </button>
    </div>
  </div>
</div>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,860评论 18 139
  • 心里堵得慌,难受
    谁都想被保护阅读 102评论 0 0
  • 我也不记得我到底是因为什么才在小学开始学了一门乐器。 那时候学校似乎是有兴趣爱好班的,是否是在某个昏暗的下午,领着...
    汪不留行阅读 220评论 1 2