Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于siblings函数的使用问题 #724

Open
sHarenZzz opened this issue May 28, 2015 · 0 comments
Open

关于siblings函数的使用问题 #724

sHarenZzz opened this issue May 28, 2015 · 0 comments

Comments

@sHarenZzz
Copy link

DOM结构为:

  • javascript
  • html
  • css

现在我使用siblings()方法来选取符合要求节点的兄弟节点。
http://docs.kissyui.com/1.4/docs/html/api/dom/siblings.html上是这么介绍siblings方法的:

然后我写了两段代码
var $lis = $('.J_Filter').all('li');
//first
var $li = $lis.siblings('li');
$('body').append("

siblings('li')过滤的结果:长度为:"+$li.length+" 节点为:"+$li.text()+" "+$li.next().text()+'

');
//second
var $li = $lis.siblings('.css');
$('body').append("

siblings('.css')过滤的结果:长度为:"+$li.length+" 节点为:"+$li.text()+'

');
结果很奇怪:
siblings('li')过滤的结果:长度为:2 节点为:html css
siblings('.css')过滤的结果:长度为:1 节点为:css

很明显第一次过滤的结果是符合文档上的描述的,但是第二次过滤的结果不是返回 javascript节点和html节点 而是css节点本身,这点让我非常费解,求大神指点迷津啊!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant