I want to use this part of code on my html page, it works fine, but I don't understand how to correct my error on the validator. I put the function in a div but in a we have the same error. Here is the link of the stackoverflow question.
This is the validator error:
Error: Attribute ontouchend not allowed on element div at this point.
Here is the css code:
:hover {
  background: red;
}
In the JS I have:
function fix() {
    var el = this;
    var par = el.parentNode;
    var next = el.nextSibling;
    par.removeChild(el);
    setTimeout(function() {
        par.insertBefore(el, next);
    }, 0);
}
And then in my HTML I have:
<a href="#" ontouchend="this.onclick=fix">test</a>
 
     
    