gpt4 book ai didi

jquery - 如何插入新元素,使其以正确的样式显示(使用 jQuery)

转载 作者:行者123 更新时间:2023-12-01 05:57:19 24 4
gpt4 key购买 nike

总的来说,我对编程还很陌生,所以我的问题可能很容易回答,甚至很愚蠢,但我在这里:

将新按钮(或任何元素)添加到我的网站时,此按钮未以正确的样式显示。我究竟做错了什么?

代码:

<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />

<script>
$(function() {
$( "#accordion" ).accordion();
});

$(function() {
$( "button" )
.button()
.click(function() {
$('#panel').append("<button>OK?</button>");
});
});
</script>

</head>
<body>
<button>Go!</button>
<div id="accordion">
<h3>Heading 1</h3>
<div>
<p id="panel">
Text
</p>
</div>
</div>
</body>
</html>

最佳答案

添加“确定”按钮后尝试此代码:

 $('#panel').append("<button>OK?</button>");
$( "#panel button" ).button();

关于jquery - 如何插入新元素,使其以正确的样式显示(使用 jQuery),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14374767/

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