Question: var items = []; var costs = []; // 2. Change all calls to document.getElementById to the jQuery $ method // 3. Replace the window.onload
| var items = []; | |||||||||||||||||||||
| var costs = []; | |||||||||||||||||||||
| // 2. Change all calls to document.getElementById to the jQuery $ method | |||||||||||||||||||||
| // 3. Replace the window.onload event with jQuery document(ready) | |||||||||||||||||||||
| // https://www.w3schools.com/jquery/jquery_syntax.asp | |||||||||||||||||||||
| window.onload = function() { | |||||||||||||||||||||
| document.getElementById('newItem').focus(); | |||||||||||||||||||||
| } | |||||||||||||||||||||
| function openTab(tabName) { | |||||||||||||||||||||
| var i; | |||||||||||||||||||||
| // 4. Change getElementsByClassName to the jQuery $ method | |||||||||||||||||||||
| var x = document.getElementsByClassName("tab"); | |||||||||||||||||||||
| for (i = 0; i < x.length; i++) { | |||||||||||||||||||||
| // 5. Change the following line style.display = "none" to hide() | |||||||||||||||||||||
| // https://www.w3schools.com/jquery/jquery_hide_show.asp | |||||||||||||||||||||
| x[i].style.display = "none"; | |||||||||||||||||||||
| } | |||||||||||||||||||||
| // 6. Change the following line style.display = "block" to show() | |||||||||||||||||||||
| https://www.w3schools.com/jquery/jquery_hide_show.asp | |||||||||||||||||||||
| document.getElementById(tabName).style.display = "block"; | |||||||||||||||||||||
| } | |||||||||||||||||||||
| function addItem() { | |||||||||||||||||||||
| var newItem = document.getElementById('newItem').value; | |||||||||||||||||||||
| var newAmount = parseFloat(document.getElementById('newAmount').value); | |||||||||||||||||||||
| costs.push(newAmount); | |||||||||||||||||||||
| items.push(newItem); | |||||||||||||||||||||
var itemsDisplay = "
| |||||||||||||||||||||
| itemsSummary += " | |||||||||||||||||||||
| Total before tax | $" + totalAmount.toFixed(2) + " | ||||||||||||||||||||
| itemsSummary += " | |||||||||||||||||||||
| Tax amount | $" + (totalAmount*.07).toFixed(2) + " | ||||||||||||||||||||
| itemsSummary += " | |||||||||||||||||||||
| Total with tax | $" + ((totalAmount*.07)+totalAmount).toFixed(2) + " |
Grocery List
Add to Shopping Cart
Current Items
Summary
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
