I have a simple question, I've the following lines which equals to not active links :
$links.not($active).each(function()
{
//Do sth...
});
what is the opposite of the .not(...)
function in JavaScript? because I need to know the active links, Any ideas !?
This is jQuery, not JavaScript. The opposite of .not
is .filter
.
您正在寻找.filter()
,它返回仅包含匹配元素的子集。
Using $links.not($active)
creates a collection with the elements from $links
except the elements in $active
.
To get the active links, just use the $active
object:
$active.each(function()
{
//Do sth...
});
The opposite of not
in programming is often named is
However this will return boolean true of false so in your case you'll be wanting filter
Example:
$links.filter('.onlyThisClass').each(function()
{
//Do sth...
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.