开发者

Jquery: How to select only within a selection?

开发者 https://www.devze.com 2023-01-31 04:37 出处:网络
var parent = $(\"#jcontent\"); var button1 = parent(\".button1\") How to select .button开发者_C百科1 knowing it is inside the parent while not reusing #jcontent?
var parent = $("#jcontent");
var button1 = parent(".button1")

How to select .button开发者_C百科1 knowing it is inside the parent while not reusing #jcontent?

I need to do this because I only want to pass the parent as parameter and to be able to cache it which is faster.


Another alternative

var parent = $("#jcontent"); 
var button1 = $(".button1", parent) ;


var button1 = parent.find(".button1");
0

精彩评论

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