Who's going to help write this regular?
For example
I want to match the class or ID of an HTML tag. (ID with ID, no take Class)
It's best to match it with a DIV or a span or something.
Share to:
------Solution--------------------
Just didn't pay attention to write it into the source code, so that the format of confusion, see as follows:
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 + = ' Neither set ID nor set class attribute ';
}
str + = ' \ntagname: ' +jquery (e). Get (0). TagName;
alert (str);
}
Point Me
Point Me
------Solution--------------------
I did not see clearly, the original span or div is not necessarily, then change//* and then nodeName get the HTML tag name.
$html = ";
$dom = new DOMDocument ();
@ $dom->loadhtml ($html);
{
echo $node->getattribute ("id"); myID
Echo '
';
echo $node->getattribute ("class"); MyClass
Echo '
';
Echo $node->nodename; Div
?>