Javascript 获取字符串并用新字符串替换div

Javascript 获取字符串并用新字符串替换div,javascript,jquery,Javascript,Jquery,在jquery中,我在页面上获得了特定div的html,并将其用作字符串。但是,您能告诉我如何删除名为“video js”的字符串中的每个类,并用另一个div替换它吗?我试图从每个“video js”div中获取一些值,然后用这些值替换为新的div 这是我到目前为止得到的,但它并没有写回字符串 var getTheCurrentResults = $(".titanLoaderControlList").html(); var obj=$(getTheCurrentResults);

在jquery中,我在页面上获得了特定div的html,并将其用作字符串。但是,您能告诉我如何删除名为“video js”的字符串中的每个类,并用另一个div替换它吗?我试图从每个“video js”div中获取一些值,然后用这些值替换为新的div

这是我到目前为止得到的,但它并没有写回字符串

var getTheCurrentResults = $(".titanLoaderControlList").html();

    var obj=$(getTheCurrentResults);
    $('.video-js',obj).each(function(){

        var theID = $(this).attr("id");
        var videoSRC = $(this).find(".vjs-tech").attr("src");
        var posterSRC = $(this).find(".vjs-tech").attr("poster");

        $(this).text("<div class='playButtonContainer'><div class='playButton'><div class='playButtonSymbol'></div></div></div><div class='videoInfo' data-video-id='"+theID+"' data-source-video='"+videoSRC+"'><img class='posterInfo' src='"+posterSRC+"'></div>");
    });
var getTheCurrentResults=$(“.titanLoaderController”).html();
var obj=$(获取当前结果);
$('.video js',obj).each(function(){
var theID=$(this.attr(“id”);
var videoSRC=$(this.find(“.vjs tech”).attr(“src”);
var posterSRC=$(this.find(“.vjs tech”).attr(“poster”);
$(此).text(“”);
});

您应该使用
.html()
替换html内容,而不是
.text()

var getTheCurrentResults=$(“.titanLoaderController”).html();
var obj=$(获取当前结果);
$('.video js',obj).each(function(){
var theID=$(this.attr(“id”);
var videoSRC=$(this.find(“.vjs tech”).attr(“src”);
var posterSRC=$(this.find(“.vjs tech”).attr(“poster”);
$(this.html(“”);
});

您应该使用
.html()
替换html内容,而不是
.text()

var getTheCurrentResults=$(“.titanLoaderController”).html();
var obj=$(获取当前结果);
$('.video js',obj).each(function(){
var theID=$(this.attr(“id”);
var videoSRC=$(this.find(“.vjs tech”).attr(“src”);
var posterSRC=$(this.find(“.vjs tech”).attr(“poster”);
$(this.html(“”);
});

请将您的html添加到问题中。你的解释不清楚。慢慢来,把它解释清楚。你能把你的html添加到问题中吗。你的解释不清楚。慢慢来,解释清楚。
var getTheCurrentResults = $(".titanLoaderControlList").html();

var obj=$(getTheCurrentResults);
$('.video-js',obj).each(function(){

    var theID = $(this).attr("id");
    var videoSRC = $(this).find(".vjs-tech").attr("src");
    var posterSRC = $(this).find(".vjs-tech").attr("poster");

    $(this).html("<div class='playButtonContainer'><div class='playButton'><div class='playButtonSymbol'></div></div></div><div class='videoInfo' data-video-id='"+theID+"' data-source-video='"+videoSRC+"'><img class='posterInfo' src='"+posterSRC+"'></div>");
});