I am trying to attach an onClick even in a span tag as like as below and would like to store it in MongoDb . but my event is not saving it is automatically removed and when I am fetching data from DB it is not available. How Can I fix it ? here is my code below
let span = document.createElement("span");
myEvent=span;
myEvent.setAttribute('onClick', 'removeElement');
here is what is storing in the db,
<span onclick="removeElement" data-highlightid="1622237808204" style="background-color: rgb(114, 76, 249); cursor: pointer;">passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a pa</span>
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment