HTML 练习on方法
2023-09-27 14:26:01 时间
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<ul>
<li>111</li>
<li>222</li>
<li>333</li>
<li>444</li>
</ul>
<input type="button" value="+" onclick="add()">
<script>
$("ul").on("click", "li", function(){
alert(888)
})
function add(){
$("ul").append("<li>555</li>")
}
</script>
</body>
</html>
on方法,传递参数
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<p>hello p</p>
</body>
<script>
function myHandler(e){
alert(e.data.foo)
}
$("p").on("click", {foo: "klvchen"}, myHandler)
</script>
</html>
相关文章
- Spark SQL与Hive on Spark的比较
- Partition does not start on physical sector boundary
- 解决方案:Vuetify 出现#activator={on,attrs}报错,类型“{ isActive: boolean; props: Record; }”上不存在属性“on”
- Visual Studio 2013 Use HTTPS (SSL) On Web Application Projects
- jQuery中on()方法用法实例
- Running ASP.NET Core applications on Windows Subsystem for Linux
- vue中使用v-bind="$attrs"和v-on="$listeners"进行多层组件监听
- Ruby on Rails
- Vue v-if v-for v-bind v-on
- Eclipse上Hadoop插件中Run On Hadoop原理[转]
- ORA-12012 Error on auto execute of job "SYS"."ORA$AT_OS_OPT_SY_<NN> in 12.2.0 Database
- Component creation must be done on Event Dispatch Thread错误解决方法
- file INSTALL cannot set permissions on “/usr/local/include/g2o/config.h“
- How to debug .NET Core RC2 app with Visual Studio Code on Windows?
- 大数据Flink(六):Flink On Yarn模式
- eclipse maven Errors while generating javadoc on java8
- supplychain on blockchain
- Large-Scale Instant Messaging Hosting on Alibaba Cloud