1-1点击事件

  1. <script >
  2. $("#app").click(function(){
  3. $(this).html("change")
  4. })
  5. </script>

1-2获取焦点/失去焦点

  1. <script src="libs/jquery-3.6.0.js"></script>
  2. <input type="text" id="app">
  3. <script>
  4. $("#app").focus(function(){
  5. $(this).css({backgroundColor:"red",width:"100px"})
  6. })
  7. $("#app").focusout(function(){
  8. $(this).css({backgroundColor:"yellow",width:"100px"})
  9. })
  10. </script>
  1. ****链式调用****
  2. <input type="text" id="app">
  3. <script>
  4. $("#app").focus(function(){
  5. $(this).css({backgroundColor:"red",width:"100px"})
  6. })
  7. .blur.focusout(function(){
  8. $(this).css({backgroundColor:"yellow"})
  9. })
  10. </script>