gpt4 book ai didi

ol 的 jQuery Children 长度

转载 作者:搜寻专家 更新时间:2023-10-31 02:24:50 25 4
gpt4 key购买 nike

我正在尝试计算 OL 的子元素

jQuery :

$(document).ready(function(){

$("#my_select").change(function(){
alert($("#ol3").children.length);
});});

HTML:

<ol id="ol1">
<li class="2">Location 1-1</li>
</ol>

<ol id="ol2">
<li class="15">Location 2-1</li>
<li class="20">Location 2-2</li>
</ol>

<ol id="ol3">
<li class="17">Location 3-1</li>
<li class="16">Location 3-2</li>
<li class="14">Location 3-3</li>
</ol>

无论ol下面有多少里,我总是得到2号。

知道发生了什么事吗?

最佳答案

尝试

$("#ol3").children().length \\ you missed () in children...

当您执行 $("#ol3").children.length 时,它会返回 .children() 函数中的参数数量...

尝试提醒 $("#ol3").children,你会得到这个...

function (d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}

df 是两个参数...这就是为什么当您发出警报时您总是在代码中得到 2..

关于ol 的 jQuery Children 长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2941057/

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