Jump to content
vamshi_26

onclick event in html string

Recommended Posts

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.

Share this post


Link to post
Share on other sites

<button onclick="someFunction()">button</button>

Have you added the quotes? The function starts on the page load?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...