我很确定这只是一个语义问题,但如果有人能引导我朝着正确的方向前进,我将不胜感激。
HTML:
<div class="grid_7">
<div class="big">
The elusive
</div>
</div>
函数:
$(function(){
$(' .grid_7 > .big').bigtext();});
我正试图捕获 .grid_7 的 child .big
这里是真实代码的链接:
http://designobvio.us/dov2/index.html
我知道这个脚本在我这样做的时候是有效的
$(function(){
$(' .grid_7:first-child').bigtext();});
一切正常...因此,它是语义?还是我疯了?
非常感谢
最佳答案
阅读有关 bigtext
plugin website 的文档:
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.
你的 .big
元素没有任何子元素 div
元素,所以什么也不会发生。
你的原因:first-child
尝试工作是:first-child
返回第一个 .grid_7
元素,而不是它的第一个子元素。
您需要申请 bigtext
.grid_7
的方法,或者您需要添加另一个 div
周围.big
.
关于javascript - 使用 jQuery 选择器从父 CLASS 选择子 ID 到子 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9358000/