8 Replies
Aldrin
AldrinOP3y ago
I want to target input tag on button click
Mannix
Mannix3y ago
what you actually want to happen when the button is clicked?
Aldrin
AldrinOP3y ago
to change the input type to password and text
13eck
13eck3y ago
You were pretty close:
console.log(this.parentElement.querySelector(".pInput"));
console.log(this.parentElement.querySelector(".pInput"));
Mannix
Mannix3y ago
i see you want to make show password thingy right?
13eck
13eck3y ago
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.
MarkBoots
MarkBoots3y ago
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
Aldrin
AldrinOP3y ago
thank you👍
Want results from more Discord servers?
Add your server