PHP implementation jquery extension function _php Tutorial

Source: Internet
Author: User
is contains this function, the book describes that this function is based on the elements of the content to filter the selected element set, when I run the code is always error, and later found that the function library does not have this function, so I wrote this function.
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.exec (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 a 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);
});
}

Running normally on IE browser, do not know what happens to other browsers?

http://www.bkjia.com/PHPjc/320723.html www.bkjia.com true http://www.bkjia.com/PHPjc/320723.html techarticle is contains this function, the book describes that this function is based on the elements of the content to filter the selected element set, when I run the code is always error, and later found that the library is not ...

  • 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.