gpt4 book ai didi

javascript - 单击按钮时清除 div(ASP.NET)

转载 作者:行者123 更新时间:2023-11-28 03:53:43 25 4
gpt4 key购买 nike

我有一个 div,我在点击按钮时附加了一些数据。这是代码

$('#display').click(function () {
$(".videolist").empty();
var vacancyId = $("#vacancy").val();
var model = {
vacancyId: vacancyId
};
var today = new Date();
var yyyy = today.getFullYear();
$.ajax({
url: '@Url.Action("Links", "Questions")',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(model),
type: 'POST',
dataType: 'json',
processData: false,
success: function (data) {
var question2 = data;

for (var i = 0; i <= question2.length - 1; i++) {
var videoHTML = '<div style="width:100%;overflow-y: scroll;background:white;height:60%;border-bottom:solid;border-color: #A9A9A9;">' + '<div style="float:left; width:50%;height:296px;border-right:solid;border-color: #A9A9A9;margin-bottom:10px;">' +
'<video style="width:100%;height:290px; object-fit: contain;padding-right: 15px;padding-left:15px;" controls>';
videoHTML += '<source src="' + document.location.origin + "/uploads/" + question2[i].Linkes + ".webm" + '" type="video/webm">';
videoHTML += '</video>' + '</div>' + '<div style="float:right;width:48%;text-align:center;height:296px;padding-top:30px;">' + '<div style="font-size:20px">' + '<b>' + question2[i].FIO + '</b>' + '</div>' + '<div style="font-size:20px">' + '<b>' + question2[i].City + '</b>' + '</div>' + '<div style="font-size:20px">' + '<b>' + (yyyy - question2[i].Vozrast) + '</b>' + '</div>' + '<div class="qustion-div-two" style="height:160px;margin-top:20px; background:white;" >' +
'<div id="comments" style="width: 100%; height: 70%;">' + '</div>' +
'<div id="write_field" style="width:100%;height:30%;">' +
'<input type="text" style="width:99%; height:75%;margin-left:2px;margin-bottom:5px;" />' + '</div>' + '</div>' + '</div>';
$(".videolist").append(videoHTML);

}
}
});
});

当我选择另一个空缺时,我会看到之前生成的 div。

我尝试通过此 $(".videolist").empty(); 清除它,但它不起作用。我的错误在哪里?

谢谢你的帮助。

最佳答案

Use this Code:

$(".videolist").html('');

它应该工作

关于javascript - 单击按钮时清除 div(ASP.NET),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43593166/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com