开发者

Jquery getting a child class of a selector retrieved using .prev

开发者 https://www.devze.com 2023-02-12 19:05 出处:网络
back = $(\"#contactus_\"+id).prev(); I\'m probably asking a simple question, but how do I get at .up_btn class from the id above?
back = $("#contactus_"+id).prev();

I'm probably asking a simple question, but how do I get at .up_btn class from the id above?

no开发者_开发知识库rmally to target this class i would do $("#contactus_"+id+" .up_btn") however in this instance I can't place the class name in there like that since I want the previous sibling's child.

Thanks


If you mean .up_btn is found in that previous sibling,

$('#contactus_' + id).prev().find('.up_btn');

To use it with the back variable,

var back = $('#contactus_' + id).prev();
var btn = back.find('.up_btn');
0

精彩评论

暂无评论...
验证码 换一张
取 消