Jarvis丶丶丶
2015-09-14 11:45
<<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>test</title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
<script src="test.js" type="text/javascript"></script>
</head>
<body>
<button>增加</button>
<ul id="ullist"></ul>
</body>
</html>
$(document).ready(function(){
$("button").click(function(){
var frag=document.createDocumentFragment();
var li=document.createElement("li");
li.innerHTML="<input id='testli' type='button' value='切换' title='1'/>";
frag.appendChild(li);
document.getElementById("ullist").appendChild(frag);
})
var getli=document.getElementsByTagName("input");
getli[0].onclick=function(){
alert("1");
}
})
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>test</title>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
<script src="test.js" type="text/javascript"></script>
</head>
<body>
<button>增加</button>
<ul id="ullist"></ul>
</body>
</html>
<script>
$(document).ready(function(){
$("button").click(function(){
var frag=document.createDocumentFragment();
var li=document.createElement("li");
li.innerHTML="<input id='testli' type='button' value='切换' title='1'/>";
frag.appendChild(li);
document.getElementById("ullist").appendChild(frag);
var getli=document.getElementsByTagName("input");
getli[0].onclick=function(){
alert("1");
}
})
})
</script>
DOM探索之基础详解篇
98374 学习 · 238 问题
相似问题