简体   繁体   中英

Convert jQuery find() function to ES6 Alternative

My task is to convert jquery to es6 . I am stuck at one point .

Jquery -

var $form = $('.class1');
commonfunction($form);

function commonfunction($form) {
  $form.find('.class2')
}

ES6 which i am working , i am trying like this .

let form = document.querySelector('.class1');
commonfunction(form);

function commonfunction($form) {
  form.find('.class2') 
}

I know that find is not supported by raw javascript .How to proceed here ?

You can do something like this

form.querySelectorAll('.class2');

More detail here

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