简体   繁体   English

使用jQuery选择器从父CLASS到子ID选择子项

[英]Selecting childs from parent CLASS to child ID using jQuery selectors

I'm pretty sure this is just a semantics problems but I would be very grateful if someone could lead me in the right direction. 我很确定这只是一个语义问题,但是如果有人可以引导我朝正确的方向前进,我将不胜感激。

The HTML: HTML:

<div class="grid_7">
  <div class="big">
    The elusive
  </div>
</div>

The function: 功能:

$(function(){
$(' .grid_7 > .big').bigtext();});

I'm trying to grab .grid_7's child .big 我正在尝试抓住.grid_7的孩子.big

Here's a link to the real code: 这是真实代码的链接:

http://designobvio.us/dov2/index.html http://designobvio.us/dov2/index.html

I know the script works cuz when i do 我知道当我这样做时脚本可以工作

 $(function(){
$(' .grid_7:first-child').bigtext();});

everything fine... therefore, it's semantics? 一切都很好...因此,这是语义吗? or am I crazy? 还是我疯了?

Thank you so much 非常感谢

Read the documentation on the bigtext plugin website : 阅读bigtext插件网站上的文档:

the BigText jQuery plugin takes a single element and sizes the text inside of its child <div> s to fit the width of the parent element. BigText jQuery插件采用单个元素,并在其子元素<div>中调整文本大小以适合父元素的宽度。

Your .big element doesn't have any child div elements, so nothing happens. 您的.big元素没有任何子div元素,因此没有任何反应。

The reason your :first-child attempt works is that :first-child returns the first .grid_7 element, not the first of its children. :first-child尝试起作用的原因是:first-child返回第一个.grid_7元素,而不是其第一.grid_7元素。

You need to apply the bigtext method to .grid_7 , or you need to add another div around .big . 您需要将bigtext方法应用于.grid_7 ,或者需要在.big周围添加另一个div

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM