像这样的事情:当我点击“添加”内容改变内容,当我点击“相当”内容回来。代码在这里。链接:
[code][1] 当我点击“添加”时,如何再次点击“相当”?
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#department a {
text-decoration: none;
}
#department span {
display: inline-block;
color: red;
margin-right: 20px;
}
#department p {
display: inline;
}
#department p span {
color: green;
font-weight: bold;
}
#department input {
width: 100px;
margin-right: 20px;
}
</style>
<script src="../jquery-1.10.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#department >p a").click(function() {
$("#department p").empty()
$("#department p").append('<input type="text" name="department"><a href="javascript:void(0)">quite</a>')
})
})
</script>
</head>
<body>
<div id="department">
<span>department</span>
<p>
<span>office</span>
<span>seek</span>
<a href="javascirpt:void(0);">add</a>
</p>
</div>
</body>
</html>
我把代码放在这里:http: //jsfiddle.net/Jackyhua/zTkXL/