gpt4 book ai didi

javascript - 在其中声明一个带有 html 的变量,并使用 .insertAfter 插入该变量

转载 作者:行者123 更新时间:2023-12-01 02:37:26 25 4
gpt4 key购买 nike

我想知道是否可以将 html 声明为变量。换句话说,像这样:

$(document).ready(function(){

var Bold="Yes! There is bold in the text above!!";
var NoBold="No... There isn't any bolded text in the paragraph above..";
var BoldButton="<input class="BoldButton" type="button" value="bold" id="WelcomeBoldButton">";

$(BoldButton)
.insertAfter('#intro');

});

然后,使用 .insertAfter 操作,以不同的时间间隔将其放入我的页面中:

$(BoldButton).insertAfter(#'intro');

这似乎不起作用,但我是否接近某些东西了?

最佳答案

你的报价被破坏了。在 " 中使用 ',在 ' 中使用 ",或转义引号。

$(document).ready(function(){

var bold="Yes! There is bold in the text above!!";
var noBold="No... There isn't any bolded text in the paragraph above..";
var $button = $("<input class='BoldButton' type='button' value='bold' id='WelcomeBoldButton'>");
$('#intro').after( $button );
});

$button.insertAfter( $('#intro') ) 也可以。

关于javascript - 在其中声明一个带有 html 的变量,并使用 .insertAfter 插入该变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3367025/

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