How do I target input tag here
8 Replies
I want to target input tag on button click
what you actually want to happen when the button is clicked?
to change the input type to password and text
You were pretty close:
i see you want to make show password thingy right?
Your existing code:
console.log(this.parentElement.pInput);
was wrong because .pInput
isn't a property on the parentElement
object, you need to use querySelector` to get the correct element.you can make it yourself a bit easier by refencing the inputfield inside the button. by id or so. The input already should have an id anyway (for the label to work)
with an inline onlick event example: https://codepen.io/MarkBoots/pen/abGjLqE
thank you👍