我如何使用uniqueId()jQuery UI

APJ*_*APJ 3 jquery jquery-ui

看来jquery ui已加载,因为当我运行时

    $(function(){
      // did the UI load?
      console.log($.ui.version);
    });
Run Code Online (Sandbox Code Playgroud)

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();
Run Code Online (Sandbox Code Playgroud)

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

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

Dip*_*ole 5

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

$(".youtube_embed iframe").each(function() {
    $(this).uniqueId();
});
Run Code Online (Sandbox Code Playgroud)