簡體   English   中英

動態添加 JQUERY 選項卡,得到“Uncaught SyntaxError: Unexpected token ILLEGAL”

[英]Dynamically adding JQUERY tabs, getting “Uncaught SyntaxError: Unexpected token ILLEGAL”

我很確定我的一個字符串中有錯誤,但我找不到它。 此代碼的目標是根據我為您工作的節目的哪一集將 Facebook 評論插件動態添加到選項卡中。

    $('body').attr('id', 'tabs');
            $( "#tabs" ).tabs();
            $('#tabs').ready(function(){discussion(222); });

                    function discussion(episodeNumber){
        var tabNum =$('#tabs').size('a') + 1;
        console.log(tabNum);
    $('#tabs').append('<div id=\"#tabs-'+tabNum+'\">'+episodeNumber+'</a></li>');
        $('#tabs-'+tabNum).ready(function(episodeNumber,tabNum){$('#tabs-'+tabNum).append('<p><div id=\"fb-root\"></div><script src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\"></script><fb:comments href=\"http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.foo.com%2Fepisodes%2Ffoo_foo_foo-'+episodeNumber+'.php&amp;h=BAQCj6iHg\" num_posts=\"10\" width=\"50\"></fb:comments></p>');
        });
        }

謝謝!

根據http://jqueryui.com/demos/tabs/的文檔,您可以通過以下方式添加選項卡:

$('#tabs').tabs('add',null,'tab label', indexId);

有關更多信息,請參閱http://jqueryui.com/demos/tabs/#method-add

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM