简体   繁体   中英

How do I select a sub element when I have selected the root using an object?

I want to bind to an element using jQuery and instead of...

jQuery('#' + obj.id)

I want to use...

jQuery(obj)

However then I need to get to a div nested within this element so what I want it something like...

jQuery(obj + 'div').doSomething()....

But that doesnt work. How do I sub select elements after selecting an element using the object directly?

ps (there is no id on the obj element (it doesnt exist)...

thanks

尝试类似的方法:

jQuery(obj).find('div')
jQuery("div", obj)

要么

jQuery(obj).find("div")

这应该工作:

jQuery('div', obj)

使用.find()方法搜索后代元素:

$(obj).find('div')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM