用jquery的一种解决方法:例子如下:
test.html:(注意,这里任何html页面都可以用,我只是在这里面加了个div
,用来显示信息。jquery.js可以在jquery上下载到,改下名字就可以,地址:http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.min.js)
jQuery Starterkit jQuery Starterkit
This page contains code to test the examples. Most of it is only relevant for a example.
Some link custom.js
//获取html的tag
$(document).ready(function() {
var arr_tag=Array();
var arr_id=Array();
var arr_class=Array();
var str='';
$('*').each(function(i){
arr_tag[i]=$(this).get(0).tagName;
arr_id[i]=($(this).attr('id')? $(this).attr('id'): 'non');
arr_class[i]=($(this).attr('class')? $(this).attr('class'): 'non');
str +=""+arr_tag[i]+" id='"+arr_id[i]+"' class='"+arr_class[i]+"'";
});
$('#gettag').html(str);
});