以下の関数は、アイコンをクリックした後に呼び出され、モーダルを作成します。関数の実行中に、DOMをたどり、HTMLキャンバスをつかみ、それをモーダルで表示します。私が抱えている問題は、最初に取得するHTMLを削除しているため、重複してほしいということです。誰かがこれについていくつかの光を当てることができますか?jQueryの重複したHTMLをBootStrapモーダルに変換
JS:
$('#chartModal').on('show.bs.modal', function (event) {
console.log('yeppp');
// Button that triggered the modal
const button = $(event.relatedTarget)
// Get corresponding chart's HTML
const chart = button.parent().next()[0]
var modal = $(this)
// Update modal's content with the corresponding chart
modal.find('.modal-body').html(chart)
})
よろしく、 ジェームズ。
'modal.find( 'モーダルボディ')HTML (chart.clone()); 'おそらく? – Snowmonkey
@Snowmonkeyはむしろ '$(chart).clone()'でなければなりませんか? 'button.parent()。next()[0]'はjQueryオブジェクトではなくノードを返します。 – dferenc
@Snowmonkey throw '' chart.cloneは関数ではありません ' –