JQuery extension functions implemented by php

Source: Internet
Author: User

It is the contains function. The book introduces that this function filters the selected Element Set Based on the element content. When I run the code, I always report an error. Later I found that this function is not available in the function library, so I wrote this function myself.
The Code is as follows: Copy codeThe Code is as follows: function yhCheckIsIncludingValue (element, pattern)
{
Var bool = false;
Var childrenNodes = element. childNodes;
If (childrenNodes. length = 0)
{
If (element. nodeValue! = Null)
{
If (pattern.exe c (element. nodeValue )! = Null)
{
Return true;
}
}
}
If (childrenNodes. length! = 0)
{
For (var I = 0; I <childrenNodes. length; I ++)
{
If (bool = yhCheckIsIncludingValue (childrenNodes, pattern) break;
}
}
Return bool;
}
// Apply this function in the function chain
$. Fn. contains = function (text)
{
Var text = $. trim (text );
If (text = 'undefined') return this;
Var pattern = new RegExp (text, 'I ');
Return this. filter (function (){
Return yhCheckIsIncludingValue (this, pattern );
});
}

It runs normally on IE. I don't know what will happen to other browsers?

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.