0

我想使用 jQuery 扫描一个 html 页面 - 在这种情况下由 WordPress 创建以查找所有指向 vimeo 视频的链接 - 由用户通过 WP 编辑管理员添加。

然后我想将这些链接的控制权传递给颜色框。

jQuery 选择器与此链接一起使用:

http://vimeo.com/44799432

// vimeo in colorbox ##
jQuery("a").filter(function(){ // filter all as ##
    return jQuery(this).text().match(/vimeo\.com/igm); // match text with vimeo.com ##
    }).colorbox({iframe:true, innerWidth: "80%", innerHeight: "80%"}) // assign to colorbox ##
    .addClass("button vimeo"); // add class to style ##

但是,vimeo 将内容推出 iframe 并重新加载页面 - 所以我需要一个匹配这个 url 的正则表达式 - 可以通过 iframe 嵌入:

http://player.vimeo.com/video/44799432

match(/player.vimeo\.com/);

不这样做 - 有什么想法吗?

注意:我显然需要一个循环来检查多个 vimeo 链接......

谢谢!

4

1 回答 1

1

试试这个(未经测试) >>

jQuery("a").filter(function() {
    return jQuery(this).text().match(/vimeo\.com/igm);
  }).each(function() { 
    this.setAttribute("href", this.getAttribute("href")
    .replace(/^https?:\/\/(?:www\.|)vimeo\.com\/(\d+)$/i,
      "http://player.vimeo.com/video/$1")); 
  }).colorbox({iframe:true, innerWidth: "80%", innerHeight: "80%"})
  .addClass("button vimeo");
于 2012-07-18T14:49:02.637 回答