Selecting elements within another element


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /*
  2. <div id="yourparent">
  3. <div id="mychild"> </div>
  4. </div>
  5. */
  6.  
  7. // Here are three ways to access an element within an element:
  8.  
  9. $('#yourparent').find('#mychild')
  10. //or even shorter:
  11. $('#mychild', $('#yourparent'))
  12. //or even shorter:
  13. $('#mychild', '#yourparent')
  14.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.