$( "html" ).parent() method returns a collection containing documents, while $( "html" ).parents() returns an empty collection. Can any expert explain it? -PHP Chinese website Q&A-The $( "html" ).parent() method returns a collection containing documents, while $( "html" ).parents() returns an empty collection. Can any expert explain it? -PHP Chinese website Q&A
$( "html" ).parent() method returns a collection containing documents, while $( "html" ).parents() returns an empty collection. Can any expert explain it? -PHP Chinese website Q&A-The $( "html" ).parent() method returns a collection containing documents, while $( "html" ).parents() returns an empty collection. Can any expert explain it? -PHP Chinese website Q&A
Please watch and learn.
parents()是取得一个包含着所有匹配元素的祖先元素的元素集合(不包含根元素),而parent()是取得一个包含着所有匹配元素的唯一父元素的元素集合。当$的对象是根元素html时,parents()就是空集合,parent()就是文档集合