More actions
No edit summary |
No edit summary |
||
| Line 4: | Line 4: | ||
// Get the span elements to be replaced | // Get the span elements to be replaced | ||
var spanElements = parentElement.getElementsByTagName('span'); | var spanElements = parentElement.getElementsByTagName('span'); | ||
// Convert spanElements to an array | |||
var spanArray = Array.from(spanElements); | |||
// Loop through each span element | // Loop through each span element | ||
spanArray.forEach(function(spanElement) { | |||
// Create the input element | // Create the input element | ||
var inputElement = document.createElement('input'); | var inputElement = document.createElement('input'); | ||
| Line 14: | Line 15: | ||
// Set any desired attributes or properties for the input element | // Set any desired attributes or properties for the input element | ||
inputElement.id = ' | inputElement.id = spanElement.id.replace('r', ''); // Replace 'r' in the ID | ||
inputElement.placeholder = 'Enter a value'; // Set a placeholder text if desired | inputElement.placeholder = 'Enter a value'; // Set a placeholder text if desired | ||
// Replace the span element with the input element | // Replace the span element with the input element | ||
spanElement.parentNode.replaceChild(inputElement, spanElement); | spanElement.parentNode.replaceChild(inputElement, spanElement); | ||
} | }); | ||
Revision as of 01:14, 25 October 2023
// Get the parent element
var parentElement = document.getElementById('simple-calc__container');
// Get the span elements to be replaced
var spanElements = parentElement.getElementsByTagName('span');
// Convert spanElements to an array
var spanArray = Array.from(spanElements);
// Loop through each span element
spanArray.forEach(function(spanElement) {
// Create the input element
var inputElement = document.createElement('input');
inputElement.type = 'text';
// Set any desired attributes or properties for the input element
inputElement.id = spanElement.id.replace('r', ''); // Replace 'r' in the ID
inputElement.placeholder = 'Enter a value'; // Set a placeholder text if desired
// Replace the span element with the input element
spanElement.parentNode.replaceChild(inputElement, spanElement);
});
//
var i = 1;
var l = 4;
var j = 1;
var k = 40;
var answers = [
(i + (i * (l - k) * 0.01) - ((i + (i * (l - 2) * 0.01)) * (j - 1) * 0.09))
];
console.log('Your answer is (' + answers[0] + ')');