append() によって表示されるフォームがあります。フォームには、js (オートコンプリート機能) で調整する必要がある入力が含まれています。はい、これ:
function addForm() {
<!-- function code here-->
...
html += ' <table class="form">';
html += ' <tr>';
html += ' <td>Entry product</td>';
html += ' <td><input type="text" name="product" value="" /></td>';
html += ' </tr>';
html += ' <tr>';
html += ' <td> </td>';
html += ' <td><div id="featured-product" class="scrollbox">';
html += ' </div>';
html += ' <input type="hidden" name="featured_product" value="" /></td>';
html += ' </tr>';
html += ' </table>';
$('#form').append(html);
}
$('input[name=\'product\']').autocomplete({
<!-- function code here-->
}
ただし、オートコンプリート機能はこの方法では機能しません。私が理解しているように、append(html) が html を DOM に保存しないためです。通常の html フォームでは問題なく動作しますが、この方法ではうまくいきません。説明どおりにフォームを作成する必要があります。質問は次のとおりです
。DOMにない要素にjsを適用するにはどうすればよいですか?
または、この要素をjsでDOMに実行するにはどうすればよいですか?
多分私はappend()のような別のものを使用する必要がありますか?
ありがとう。