Which expert helps to write this regular

Source: Internet
Author: User
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

?>
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.