coolio83000 coolio83000 - 1 year ago 82
HTML Question

ontouchend attribute has validation error but works fine

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

but in
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;
setTimeout(function() {
par.insertBefore(el, next);
}, 0);

And then in my HTML I have:

<a href="#" ontouchend="this.onclick=fix">test</a>

Answer Source

The ontouchend attribute is not standardized. It is even not widely supported. This means you can use it in some browsers, but validators will throw warnings.

You can simply ignore it, when it works for you. But this don't mean that this attribute behavior meight not change in the future.


This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

Note: This attribute has not been formally standardized. It is specified in the Touch Events – Level 2 Editor's Draft specification and not in Touch Events Recommendation. This attribute is not widely implemented.

Read more about the attribute in the MDN docs here and here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download