poner valores por defecto en los inputs de mi html in javascript

To set default values for HTML inputs using JavaScript, you can use the defaultValue property of the DOM input element. Here's an example:

<!-- Example input element with default value set using JavaScript -->
<input type="text" id="myInput">
104 chars
3 lines
index.tsx
// Get the input element
var myInput = document.getElementById("myInput");

// Set the default value using JavaScript
myInput.defaultValue = "Default value";
158 chars
6 lines

In this example, the defaultValue property of the input element is set to "Default value". This will set the initial value of the input element to "Default value" when the page is loaded.

You can use this method to set default values for different types of input elements (e.g. text, number, checkbox, etc.). Just make sure to get the correct element using its ID or other selector, and set the defaultValue property to the desired value.

gistlibby LogSnag