jQuery first child of “this”

后端 未结 10 1163
暖寄归人
暖寄归人 2020-12-04 05:48

I\'m trying to pass \"this\" from a clicked span to a jQuery function that can then execute jQuery on that clicked element\'s first child. Can\'t seem to get it right...

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-04 06:14

    Have you tried

    $(":first-child", element).toggleClass("redClass");
    

    I think you want to set your element as a context for your search. There might be a better way to do this which some other jQuery guru will hop in here and throw out at you :)

提交回复
热议问题