【问题标题】:Using this keyword to select children使用这个关键字来选择孩子
【发布时间】:2014-02-15 09:53:43
【问题描述】:

$this 关键字在选择子元素时的语法是什么?

For example when selecting images of the first cell in a table: $("this td:eq(0) img"), or, $($this "td:eq(0) img"), etc, like should there be quotes, a dollar sign etc, and if so, where?

【问题讨论】:

    标签: jquery this children


    【解决方案1】:

    为什么不只是 find() 函数?

    $(this).find('td:eq(0) img');
    

    【讨论】:

    • 你可以使用 css() 和 find() 吗,例如 $this.find('td:eq(0) img').css("width", "200px")?
    • 当然。 find()返回一个jQuery对象,和$()一样。
    • 抱歉来晚了,但是 find(elementname).hover(function(){code}) 有效,谢谢。
    猜你喜欢
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多