e
が作成されるとすぐに$(e).append()
を使用します。JQuery作成するとすぐに親に追加する
私はそれを使用することができます知っている:setTimeout(/*func checking if parent exists*/, 100)
しかし、私は本当に悪いアイデアを見つける。 DOM要素のサブツリーが変更されたときに発生する、ある種のDOMイベントがありますか?
私は通常、ソースコード、親を作成する関数に貼り付けますが、実際にはChrome拡張機能を実際に作成しているため実際には不可能です。私はあなたはそれが本当に使いやすいです見ることができるようにArrive.js
// watch for creation of an element which satisfies the selector ".test-elem"
$(document).arrive(".test-elem", function() {
// 'this' refers to the newly created element
var $newElem = $(this);
});
// the above event would watch for creation of element in whole document
// it's better to be more specific whenever possible, for example
$(".container-1").arrive(".test-elem", function() {
var $newElem = $(this);
});
存在する要素を待っているため、このライブラリを使用することになり、あなたの助け
ん「E」であると仮定しますか? – Grommy
親にmutation observerを使用して、すべてが追加されていることを確認できます(https://developer.mozilla.org)。$(window).load(function(){ .... }/ja/docs/Web/API/MutationObserver –
@Glumyいいえ、それはajaxの結果に応じて動的に作成されます –