3

似乎 jquery ui 已加载,因为当我运行时

    $(function(){
      // did the UI load?
      console.log($.ui.version);
    });

JS 控制台返回 1.10.3

我正在使用 gem https://github.com/joliss/jquery-ui-rails(最新)和https://github.com/rails/jquery-rails版本 2.1.4

我正在尝试为每个 youtube 嵌入的 iframe 生成唯一 ID

$(".youtube_embed iframe").each.uniqueId();

我做对了吗?我在 JS 控制台中收到此错误:

Uncaught TypeError: Object function ( callback, args ) {
    return jQuery.each( this, callback, args );
} has no method 'uniqueId' 1:938
(anonymous function)
4

1 回答 1

6

您应该迭代每个匹配的元素并为每个元素分配一个唯一的 id。

$(".youtube_embed iframe").each(function() {
    $(this).uniqueId();
});
于 2013-08-16T06:10:50.113 回答