0

ページの下部にある別の div からコンテンツを取り込むブートストラップ ポップオーバーを使用したポップオーバー ダイアログがあります。

html は次のようになります。

私がループしてポップアップを添付している要素:

<sup id="cite_ref-3-0" class="reference bootstrap-footnote" data-original-title="">
  [<a href="#cite_note-3">3</a>]
</sup>

ポップアップを生成する参照を含むドキュメントの下部:

<li id="cite_note-1">
    <b><a href="#cite_ref-1-0">^</a> </b> 
    <a target="_blank" href="http://www.guardian.co.uk/music/musicblog/2009/aug/17/major-labels-spotify/">
         "Behind the music: The real reason why the major labels love Spotify"
    </a> 
    <i>The Guardian.</i>  17 August 2009
</li>

そして、ページ上のすべての参照を反復処理する jquery 関数がありますが、ポップオーバーを設定する前に html を解析する方法がわかりません。<b>タグも中身も全部外したいです。

変数で .remove("b") のさまざまな組み合わせを試しましたが、役に立ちませんでした。私は何が欠けていますか?

        $element
            .addClass("bootstrap-footnote")
            .each(function(i,item) {
                var footnote_ref = $("a", this).attr("href");
                var footnote_val = $(footnote_ref).html(); //remove("b")
                var footnote = footnote_val; //remove("b")
                $(item).popover({
                    html: true,
                    title: null,
                    content: footnote,
                    delay: { show: 50, hide: 1500 },
                    //placement: "bottom",
                    trigger: "hover"
                });
            });
4

1 に答える 1

1

私はあなたが今何を望んでいるかを理解していると思います

$element.addClass("bootstrap-footnote").each(function(i, item) {        
    var liID = $('a',this).attr('href'); // this is your li's id
    var footnote = $(liID).clone().find('b').remove().end();   // clone the li - remove b

    $(item).popover({
        html: true,
        title: null,
        content: footnote.html(),
        delay: {
            show: 50,
            hide: 1500
        },
        //placement: "bottom",
        trigger: "hover"
    });
});​
于 2012-10-26T19:05:49.147 に答える