I have a problem with duplicate ids in my html page.
Sometimes I need to get and id value from a class in Jquery, so:
<span class='click' id='23'>Click</span>
And in another class I have the same id:
<span class='classtow' id='23'>Click class two</span>
It works fine for Jquery, since it is a different function to get class id:
$(".click").click(function(){
var element = $(this);
var I = element.attr("id");
});
$(".classtwo").click(function(){
var element = $(this);
var I = element.attr("id");
});
But it doesn't pass on HTML validation. What would be the best practise to solve this?
I Know id must be unique, what I want to know is how could I solve this situation (knowing that I need to use the 23 value for both - it is an user ID that I need to get on click)