我如何使用uniqueId()jquery ui
似乎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)
您应该迭代每个匹配元素并为每个元素分配唯一的ID。
$(".youtube_embed iframe").each(function() { $(this).uniqueId(); });