Walk all DOM elements with jQuery


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

This code will walk all elements from a given selector.


Copy this code and paste it in your HTML
  1. function doStuff(child, type) {
  2. if(typeof type !== 'undefined' && type != ""){
  3. /** HERE **/
  4. }
  5. }
  6.  
  7. function walk(children){
  8. if (typeof children == "undefined" || children.size() === 0) {
  9. return;
  10. }
  11.  
  12. children.each(function(){
  13. var child = $(this);
  14. if (child.children().size() > 0) {
  15. walk(child.children());
  16. }
  17. doStuff(child, this.type);
  18. });
  19. }
  20.  
  21. walk($("#ka-registration-vital-information-form .participant"));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.