Markup Validation Error: "Duplicate ID" #HTML5
@admin
Updated July 12, 2013 ● 1,284 views
Updated July 12, 2013 ● 1,284 views
Programming
Another lesson learned while building this website. After doing a markup validation, I get a couple of "Duplicate ID" errors at the frontpage. Since the content list is generated from the database, the same element ID was generated on each list.
<a href="javascript:void(0);" id="likeItem" data-index="0">like</a>
To resolve the duplicate ID error, I removed the element ID and used data attribute instead.
<a href="javascript:void(0);" data-action="like" data-index="0">like</a>
<script type=\"text/javascript\">
/*<![CDATA[*/
jQuery(function($) {
jQuery('body').on('click','a[data-action="like"]',function(){
jQuery.ajax({
-------
});
});
});
/*]]>*/
</script>
1 Comments
Related
More in Programming
▶︎
I just put my site on validator... damn... I see the same errors. Thanks for the tip.
master_yii · 11 years agopermalink · reply (0)