Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:BakiDance/common.js: Difference between revisions

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
for (var i = 0; i < spanElements.length; i++) {
spanArray.forEach(function(spanElement) {
  var spanElement = spanElements[i];
 
   // 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 = 'inputElementId' + i; // Set a unique ID for each input element
   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] + ')');