时间:2021-07-01 10:21:17 帮助过:9人阅读
function getTagInfo(e){
var str='';
if(jQuery(e).attr('id')){
str += 'id:'+jQuery(e).attr('id');
}else if(jQuery(e).attr('class')){
str += 'class:'+jQuery(e).attr('class');
}else{
str += '既没设置id也没设置class属性';
}
str += '\ntagName:'+jQuery(e).get(0).tagName;
alert(str);
}
点我
点我
$html = '';
$dom = new DOMDocument();
@$dom->loadHTML($html);
$x = new DOMXPath($dom);
foreach($x->query("//*") as $node)
{
echo $node->getAttribute("id"); //myid
echo '
';
echo $node->getAttribute("class"); //myclass
echo '
';
echo $node->nodeName; // div
}
?>