gpt4 book ai didi

jquery - 用jquery选择第一个 child

转载 作者:行者123 更新时间:2023-12-03 22:06:25 40 4
gpt4 key购买 nike

我正在尝试选择 ul 的第一个子级,然后将其删除,然后将其附加到该 ul 的末尾,但不幸的是我无法选择第一个子级。

这是代码

current = 0;
$(document).ready(function(){

width=951;

var totalSlides=$(".slider ul li").length;
$(".slider ul").removeAttr('width');
$(".slider ul").attr('width',width*totalSlides);

$('#next img').click(function(){
current -= width;
$(".slider ul").animate({"left":current+"px"}, "slow");
$(".slider ul").append($(".slider ul:first-child"));
//$('.slider ul:firstChild').remove();
});
});

最佳答案

您不需要 .remove()help.detach()help将其附加到其他位置的节点。您只需调用 .append()help 即可做到这一点或.appendTo()help分别.after()help.insertAfterhelp 。例如:

$('ul li:first').insertAfter('ul li:last');

演示:http://www.jsfiddle.net/KFk4P/

关于jquery - 用jquery选择第一个 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4891579/

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