Javascript 如何在Prototype中重新实现外部弹出jQuery代码?
我在jQuery中有这段代码,我想用原型库重新实现它Javascript 如何在Prototype中重新实现外部弹出jQuery代码?,javascript,jquery,popup,prototypejs,Javascript,Jquery,Popup,Prototypejs,我在jQuery中有这段代码,我想用原型库重新实现它 // make external links open in popups // this will apply a window.open() behaviour to all anchor links // the not() functions filter iteratively filter out http://www.foo.com // and http://foo.com so they don't trigger off
// make external links open in popups
// this will apply a window.open() behaviour to all anchor links
// the not() functions filter iteratively filter out http://www.foo.com
// and http://foo.com so they don't trigger off the pop-ups
jQuery("a[href='http://']").
not("a[href^='http://www.foo.com']").
not("a[href^='http://foo.com']").
addClass('external');
jQuery("a.external").
not('a[rel="lightbox"]').click( function() {
window.open( jQuery(this).attr('href') );
return false;
});
如何使用jQuery中列出的not运算符的等效项迭代筛选元素集合?可以使用如下拒绝方法进行筛选:
$$('a').reject(function(element) { return element.getAttribute("href").match(/http:\/\/(www.|)foo.com/); }).invoke("addClassName", "external");
可以使用如下所示的拒绝方法进行过滤:
$$('a').reject(function(element) { return element.getAttribute("href").match(/http:\/\/(www.|)foo.com/); }).invoke("addClassName", "external");