[Solved] Add new class and attributes to div if it exists on the page [duplicate]


Try $().length property instead, and place this snippet at the very bottom of the page, before closing body tag

<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
    if ($('.toplink').length > 0) {
        $('.toplink').addClass('adin').attr('data-aid', '114');
    }
});
</script>

2

solved Add new class and attributes to div if it exists on the page [duplicate]