gpt4 book ai didi

javascript - 我如何将下拉列表 html/css 附加到 jquery 1 行正文

转载 作者:太空宇宙 更新时间:2023-11-04 10:12:20 25 4
gpt4 key购买 nike

我想使用 html/css 添加下拉框。问题是我体内只有一个 id,所以我不知道该怎么做。如果有人可以发布以下代码的示例,将不胜感激。

我发现了类似的东西,但我不确定如何在我的代码中设置 id,也不确定这是否可以。

var someElement = $('<div/>', {id: 'someId'); $('canvas').after(someElement);  $('#someId').doMoreStuff

代码如下:

    <head>
<title>jTournament</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="jTournament.js"></script>

<script>
var matchInfo = {
"rounds": [{
"name": "Round1",
"matches": [{
"p1": "Bill",
"p2": "Bob",
"winner": 1
}, {
"p1": "Sam",
"p2": "Duddly",
"winner": 2
}, {
"p1": "Andy",
"p2": "Biff",
"winner": 1
}, {
"p1": "Phill",
"p2": "Peter",
"winner": 1
}, {
"p1": "John",
"p2": "Dave",
"winner": 2
}, {
"p1": "Xaus",
"p2": "James",
"winner": 2
}, {
"p1": "Kenny",
"p2": "Nick",
"winner": 1
}, {
"p1": "Fred",
"p2": "Pat",
"winner": 2
}]
}, {
"name": "Round2",
"matches": [{
"p1": null,
"p2": null
}, {
"p1": null,
"p2": null
}, {
"p1": null,
"p2": null
}, {
"p1": null,
"p2": null
}]
}, {
"name": "Round3",
"matches": [{
"p1": null,
"p2": null
}, {
"p1": null,
"p2": null
}]
}, {
"name": "Round4",
"matches": [{
"p1": null,
"p2": null
}, ]
}]
};
</script>
</head
<body>
<canvas id="tournament"></canvas>
</body>

我想添加下拉菜单,这样我就可以动态地连接内容。谢谢

最佳答案

您可以使用以下方法在 Canvas 后添加新元素:

$('#tournament').after('<div id="newid"></div>');

现在如果你想添加一些东西您可以使用 append() 函数

$('#newid').append('<select></select>');

如果需要其他任何东西,请查看此链接 http://api.jquery.com/append/

关于javascript - 我如何将下拉列表 html/css 附加到 jquery 1 行正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37503206/

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