【发布时间】:2016-12-06 01:43:15
【问题描述】:
如果我们将 Html 推送到 Dom ,它将在那里显示但不会更新。 jQuery有更新功能吗?
$(function(){
$('#add').on('click', function(){
$('.outer').append('<div class="data"><input type="text" value="enter" /><a href="#" class="remove">Remove</a></div>');
});
$('.remove').on('click', function(){
alert('not working');
});
});
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<div class="outer">
<input type="button" value="Click me" id="add" />
</div><!-- /.outer -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</body>
</html>
当我们推送到DOM 时,锚链接不起作用,必须感谢每个答案?
【问题讨论】:
-
您需要使用后端服务来存储数据。所以,即使你刷新。数据仍然存在。
-
不需要后端,我们可以通过本地存储使用javascript或jQuery来完成
标签: javascript jquery html css