jQuery関数を使用して繰り返しhtmlを作成します。
$.append()
、$.before()
、$.after()
などを使用して、関数に柔軟性を持たせたいと思います。
現在、私は次のようなことをしています
$.fn.appendRecurringHTML = function(domInsertMethod, domInsertID, htmlToInsert) {
if(domInsertMethod == 'append'){
$(domInsertID).append(htmlToInsert);
}
else if(domInsertMethod == 'before'){
$(domInsertID).before( ...
}
しかし、私は(疑似)を好むだろう
$.fn.appendRecurringHTML = function(domInsertMethod, domInsertID, htmlToInsert) {
$(domInsertID).window[domInsertMethod](htmlToInsert);
}
しかし、それは私にはうまくいきません。
これは可能ですか?もしそうなら、どのように?