
获取input的值,可以使用val()命令,
创建内容可以使用$()
插入到ul可以使用appendTo()来插入。
下面是一个示例:
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="js/jquery-3.3.1.js"></script>
</head>
<body>
<input type="text" name='box'>
<button>插入</button>
<ul></ul>
<script>
$('button').click(function() {
var text = $('input[name="box"]').val()
$('<li>' + text + '</li>').appendTo($('ul'))
})
</script>
</body>
</html>
function tog(id){
var obj=document.getElementById(id)
if(obj.style.display=="none")
{
obj.style.display=""
}
else
{
obj.style.display="none"
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)