I just want to know if i did this right, regarding js and react script

function clickfunction() { const p = document.querySelector('.container') p.styles.padding = "50px"; } export function App2() { return <div> <p>Hello Again</p> <div>
<p onclick="clickfunction" className="container1">djskahdasfklaskl</p> </div> </div> }
4 Replies
chrono1913
chrono1913OP3y ago
so basically i want to create a function that will active on click so I placed the onclick in the <p> tag and the className. I want to click on the text and make the text padding 50px I also tried something like this const p = document.querySelector('.container1') const ptag = document.querySelector('.ptag') p.addEventListener('click', ptag.styles.padding = "50px" )
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
chrono1913
chrono1913OP3y ago
o so stuff like add eventlistner and all those other function wont work?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server