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