Markup Validation Error: "Duplicate ID" #HTML5


Updated July 12, 2013 ● 1,284 views

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

0

I just put my site on validator... damn... I see the same errors. Thanks for the tip.

master_yii · 11 years ago
permalink · reply (0)

This website uses cookies. By continuing to use this site, you are accepting our Privacy Policy and Terms of Service.