I am getting one validation error due to my use of data-href=\"\" in the context of making a whole DIV clickable. The JS and HTML is below. What could I do to make this W3C
You cool with adding the attribute through jQuery? Or do we need a more dynamic solution?
$(".linked").attr('data-href', 'link.html').click(function(){
window.location = $(this).attr("data-href");
return false;
});
also:
Considering that this isn't a WC3 compliant method have you thought about moving this into the Title attribute? Remove the '.html'line, and in your click function:
HTML:
jQuery
$(".linked").click(function(){
var dataHref = $(this).attr('title');
window.location = dataHref.html;
return false;
});
Then again, we run into issues with propagation. I don't know how your links are being propagated, whether you hard-code them or you dynamically create them with server side script, so the latter and previous solutions still not might be good enough for you.
I was downvoted, as the OP said that the solution provided did not work -- The solution provided works completely fine. Please see the fiddle below, and make sure you don't have errors in your javascript before you downvote someone.
http://jsfiddle.net/n68A8/