我动态创建了一个 div,加载了另一个 html 的一些代码,并将其加载到一个静态元素中。
var myDiv = document.createElement('div');
$(studentReports).attr('id', 'studentReports');
$(studentReports).load('reports_tables.html .studentReports');
$(reports).append(studentReports);
//The element *reports* is in DOM, has an id="reports"
//among his clases it has the class="reports"
在这一点上,它工作得很好,但是当我尝试指向学生报告并附加文本时,它不起作用
我尝试使用的方法是我在这里搜索的以下方法:
$('body').find('.studentReports').append( ... );
$('#reports').find('.studentReports').append( ... );
$('.studentReports', '.reports').append( ... );
$('div.reports div.studentReports').append( ... );
Load 采用一个可选的 complete 方法,该方法将在加载完成时执行。为了保证响应中的内容存在于您的页面上,您需要将辅助逻辑作为此完整回调逻辑的一部分。喜欢...
$(myDiv).load('hmlFile.html .dynamicElementClass', function(){
$('body').find('.dynamicElementClass').append( ... );
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句