whalesea

jquery绑定点击事件的三种写法

一、用jquery动态绑定点击事件的写法

部分代码:

 

<script type="text/javascript">
$(document).ready(function(){
    $("#text").bind("click",function(){
        alert("我的id为text,你点击时触发");
    });
    
    $("#text1").on("click",function(){
        alert("hellworl");
    });
    
    $("#text2").click(function(){
        alert($("#text2").val());
        
    });
});
    
    
</script>
<body>
    
    <input id="text" type="button" value="点击"/> 
    
    <input id="text1" type="button" value="点击"/> 
    
    <input id="text2" type="text" value="love"/> 
</body>

 

 

 

  

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-02-07
  • 2021-06-30
  • 2021-06-23
相关资源
相似解决方案