vamshi_26 Posted February 7, 2019 Share Posted February 7, 2019 I have a use case where my content editable div accepts only string inside it but it shows the html elements as they are supposed to be shown on website but as per the configurations mentioned in package. They have mentioned the attributes but not click events. Now, if I have string as `some text here <button onclick=someFunction()>button</button>`. Here someFunction is directly being called without triggering button because I think it is in string. How can I call `someFunction()` only when button is clicked. Link to comment Share on other sites More sharing options...
smus Posted February 7, 2019 Share Posted February 7, 2019 <button onclick="someFunction()">button</button> Have you added the quotes? The function starts on the page load? Link to comment Share on other sites More sharing options...
shaili_shah Posted November 1, 2019 Share Posted November 1, 2019 i think you need to add double quotes arround function name <button onclick = "someFunction()" >button</button> Link to comment Share on other sites More sharing options...
dsonesuk Posted November 1, 2019 Share Posted November 1, 2019 I'm sure I've seen that same answer before, but I can't in the life of me remember where? Link to comment Share on other sites More sharing options...
Sherin Posted January 6, 2020 Share Posted January 6, 2020 Try using this way : <button onclick = "someFunction()">Button</button> Else you can even try : <button class="someFunction">button</button> <script> $(".someFunction").click(function(){ alert("This is a function"); }); </script> 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now