Как я могу переопределить внешний всплывающий код jQuery в Prototype?

StackOverflow https://stackoverflow.com/questions/85887

Вопрос

У меня есть этот код в 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;
});

Как вы можете итеративно фильтровать коллекцию элементов, используя эквивалент операторов not (), перечисленных здесь, в jQuery?

Это было полезно?

Решение

Фильтрация может быть выполнена с помощью метода отклонения следующим образом:

$$('a').reject(function(element) { return element.getAttribute("href").match(/http:\/\/(www.|)foo.com/); }).invoke("addClassName", "external");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top