我想在表头上附加一段html(几格),是否可以将html存储到一个变量中并附加它?
这是我的html,我希望将其存储在$ sliders_row之类的变量中,遍历每个结果(使用$ .each()),并将其附加到我的表头中:
<tr class="">
<td>' + this.id + '</td>
<td>' + this.title + '</td>
<td>' + this.description + '</td>
<td>' + this.image + '</td>
<td>' + this.isVisible + '</td>
<td class="entry_table_options_container">
<i class="fa fa-info-circle" data-id="+ this.id +" data-title="+ this.title +" data-content="+ this.description +" data-image="+ this.image +" title="Ver" style="background-color:#77DD77;"></i>
<i class="fa fas fa-pencil-alt " data-id="+ this.id +" data-title="+ this.title +" data-content="+ this.description +" data-image="+ this.image +" title="Editar" style="background-color:#5BC0DE;"></i>
<i class="fa far fa-trash-alt " data-id="+ this.id +" data-title="+ this.title +" data-content="+ this.description +" data-image="+ this.image +" title="Borrar" style="background-color:#D9534F;"></i>
</td>
</tr>
这是我的JQuery AJAX代码:
var linked_entry;
var csrf = $('meta[name=csrf-token]').attr('content');
console.log(csrf);
$('.form_show_results').click(function(){
linked_entry = $(this).attr("data-link");
$.ajaxSetup({
headers: { 'X-CSRF-Token' : $('meta[name=csrf-token]').attr('content') }
});
$.ajax({
type: 'GET',
url: '/' + linked_entry + '',
success: function(data) {
console.log(data);
$('.form_table_results').removeClass('visible');
$('.form_table_results[data-link=' + linked_entry + ']').addClass('visible');
$.each(data, function () {
$('.entry_table_container[data-link=' + linked_entry + ']').append('');
});
},
error: function(data) {
alert('Something failed');
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
我也使用点语法吗?