Skip to main content
How can we find the default value of any lightning input in LWC after it has been changed by the user.

 

Like we could do something like document.getElementById('id').getAttribute('value') in normal HTML and JS on the onchange event to get the defualt value of input.

 

So how to achieve the same thing in LWC?

 

 
7 risposte
  1. 20 mag 2020, 10:33
    Ok, so you mean it is not possible to getAttribute from lightning-input elements.

     

    handleinputchange(event) {

     

        console.log(event.target.value);

     

    }

     

    The above piece works perfectly and I have used it already but it gives you the current value of that input field in context.

     

    However HTMLElement.getAttribute('value') is used to fetch the initial value of that input.

     

    Thank you for sharing your knowledge.