質問

私はこのコード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 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;
});

どのようにすることができますを繰り返フィルタは、要素のコレクションの使用と同等のない()事業者のことをマウスでクリック?

役に立ちましたか?

解決

フィルタリングでの使用を拒否する方法はこのように:

$$('a').reject(function(element) { return element.getAttribute("href").match(/http:\/\/(www.|)foo.com/); }).invoke("addClassName", "external");
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top