3
append()에 의해 나타나는 양식이 있습니다. 양식에 js (자동 완성 기능)로 조정해야하는 입력이 들어 있습니다. 여기 가 있습니다 :append()를 사용하여 만든 요소에 자바 스크립트를 적용하는 방법은 무엇입니까?
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에이 elemnt를 어떻게 실행할 수 있습니까?
아마도 append()와 같은 다른 기능을 사용해야합니다.
감사합니다.
오 감사 트래비스! 존경! – Sergey