别照老师教的作,肯定实现不了,不知道为什么
别照老师教的作,肯定实现不了,因为没有 e.preventDefault();语句,所以实现不了
别照老师教的作,肯定实现不了,因为没有 e.preventDefault();语句,所以实现不了
2018-12-08
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<script src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<body>
<div class="container">
<div class="row">
<div class="col-md-5">
<form action="" id="todoForm">
<label for="">xxxx</label>
<input type="text" id="todoInput" class="form-control">
</form>
<p id="todoCount"></p>
<ol id="todoList"></ol>
</div>
</div>
</div>
<script>
(function(){
var $todoForm=$("#todoForm");
var $todoInput=$("#todoInput");
var $todoList=$("#todoList");
$todoForm.submit(function(e){
e.preventDefault();
var input_value = $todoInput.val();
$todoList.append('<li>'+input_value+' <a href="#" class="todoDelete">X</a></li>');
$todoInput.val('');
});
})();
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<script src="http://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<body>
<div class="container">
<div class="row">
<div class="col-md-5">
<form action="" class="todoForm">
<label for="">xxxx</label>
<input type="text" id="todoInput" class="form-control">
</form>
<p class="todoCount"></p>
<ol id="todoList"></ol>
</div>
</div>
</div>
<script>
(function(){
var $todoForm=$("#todoForm");
var $todoInput=$("#todoInput");
var $todoList=$("#todoList");
$todoForm.submit(function(e){
var input_value = $todoInput.val();
$todoList.append('<li>'+input_value+' <a href="#" class="todoDelete">X</a></li>');
});
})();
</script>
</body>
</html>
举报