日期:2014-05-16 浏览次数:20461 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type='text/css'>
dl dt { width:100px; float:left; }
dl dd { margin-left:200px; }
</style>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
<script type='text/javascript'>
var clone;
$(function() {
$('dl dd').click(function() {
$(this).html("<input type='text' /> <select><option value='Work'>Work</option></select> <span class='close'>x</span><br /><span class='another'>Add another</span>");
clone = $(this).clone(true);
});
/*$('.close').live('click', function() {
$(this).parent().html('Add a phone number');
});*/
$('dl dd').delegate('.close', 'click', function(e) {
//$(this).parent().html('Add a phone number');
e.stopPropagation();
$(this).parent().html('Add a phone number');
});
/*$('dl dd input').keydown(function() {
$('this').parent().append("<br /><span class='another'>Add another</span>");
});*/
$('dl dd').delegate('input', 'click', function(e) {
e.stopPropagation();
});
/*$('.another').live('click', function() {
$(this).parent().parent().append(clone);
});*/
$('dl').delegate('.another', 'click', function(e) {
e.stopPropagation();
$(this).parent().parent().append(clone);
});
});
</script>
</head>
<body>
<dl>
<dt>Phone</dt>
<dd class='dd'>Add a phone number</dd>
</dl>
</body>
</html>