首页 > 其他 > 详细

第06章 DOM节点操作(下)

时间:2015-07-04 02:08:00      阅读:237      评论:0      收藏:0      [点我收藏+]

index.html

<!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>DOM 节点操作</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="demo.js"></script>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
	<div class="box">节点</div>
	<div>节点</div>
</body>
</html>

?

demo.js

$(function(){
	//$(‘div‘).wrap(‘<strong class="bbb"></strong>‘);
	//$(‘div‘).wrap(‘<strong/>‘);
	//$(‘div‘).wrap(‘<strong>onestopweb</strong>‘);
	//$(‘div‘).wrap(‘<strong><em></em></strong>‘);
	
	//$(‘div‘).wrap($(‘strong‘).get(0));
	//$(‘div‘).wrap(document.createElement(‘strong‘));
	/*
	$(‘div‘).wrap(function(index){
		return ‘<strong>‘+index+‘</strong>‘;
	});
	*/
	//$(‘div‘).wrap(‘<strong><em></em></strong>‘);
	//$(‘div‘).unwrap();
	//$(‘div‘).unwrap();
	
	//$(‘div‘).wrap(‘<strong><em></em></strong>‘);
	//$(‘div‘).wrapAll(‘<strong><em></em></strong>‘);
	//$(‘div‘).wrapAll(document.createElement(‘strong‘));
	//$(‘div‘).wrapInner(‘<strong><em></em></strong>‘);
	//$(‘div‘).wrapInner(document.createElement(‘strong‘));
	/*
	$(‘div‘).wrapInner(function(index){
		return ‘<strong>‘+index+‘</strong>‘;
	});
	*/
	
	$(‘div‘).click(function(){
		alert(‘oneStopWeb.cn‘);
	});
	//$(‘div‘).clone().appendTo(‘body‘);
	//$(‘div‘).clone(true).appendTo(‘body‘);
	//$(‘div‘).remove(‘.box‘);
	//$(‘div.box‘).remove();
	//alert($(‘div‘).remove().get(0));
	//$(‘div‘).remove().appendTo(‘body‘);
	//$(‘div‘).detach().appendTo(‘body‘);
	
	//$(‘div‘).empty();
	//$(‘div‘).replaceWith(‘<span>DOM</span>‘);
	$(‘<span>DOM</span>‘).replaceAll(‘div‘);
});

?

?

?

?

第06章 DOM节点操作(下)

原文:http://onestopweb.iteye.com/blog/2224157

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!