javascript trigger button click using class name 1

javascript trigger button click using class name

//The following code assumes that the given element has both of those classes;
document.querySelector('.rateRecipe.btns-one-small').click();

//In the following code, the space is meant to imply an ancestor-descendant relationship
document.querySelector('.rateRecipe .btns-one-small').click();

Here is what the above code is Doing:
1. The first line of code is selecting the element with the class of rateRecipe.
2. The second line of code is selecting the element with the class of btns-one-small that is a descendant of the element with the class of rateRecipe.

Similar Posts