Markup Validation Error: "Duplicate ID" #HTML5


Updated July 12, 2013 ‚óŹ 1,009 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 · 5 years ago
permalink · reply (0)



Our Terms of Use and Privacy Policy have changed.
By continuing to use this site, you are agreeing to the new Privacy Policy and Terms of Use.