Latest solutions
Latest comments
- @hariprasad9899Submitted almost 3 years ago@hariprasad9899Posted almost 3 years ago
Opps ! due to extended monitor issues ! i am missing some backgrounds and colors
0 - @catherineisonlineSubmitted about 3 years ago@hariprasad9899Posted about 3 years ago
Really likes the way you structured your script and CSS code. I'll try like this !!
0 - @julabinaSubmitted about 3 years ago@hariprasad9899Posted about 3 years ago
Hi,
Just a suggestion for precise js. Instead of adding an event listener for every tipstipsAmount[1....5], create a for loop and iterate over it for each tipsAmount in a single block. Like the below.
for ( let i = 0; i < tipsAmount.length;i++ ){
customVal = 0; customAmount.value = ""; if (tipsAmount[i].classList.contains("left__selectTips__cont__amount--selected")) { tipsAmount[i].classList.remove("left__selectTips__cont__amount--selected"); tipPercent = 0; } else { resetSelectedAmount(); tipsAmount[i].classList.add("left__selectTips__cont__amount--selected"); tipPercent = 5; } calcul();
}
this will add an event listener to all the buttons, as you wish.
Happy Coding !! :)
0 - @sansanthiSubmitted about 3 years ago@hariprasad9899Posted about 3 years ago
you just nailed it with the JS code. Just view my js code for this lol ! I complicated too much and you did it like ' hold my beer ' ! :)
Marked as helpful0