in my website i have to create dynamic elements.
some elements have lots of properties like: id, class, title, href for links etc...
i was looking at some example on different sites and i saw 2 different way i can build my code
#1 static
$('#mydivid').html('<a href="http://domain.com/page.html" title="my link" id="linkid" class="links-green">link</a>');
#2 dynamic
var anchor = $('<a />', {
className: 'links-green',
id: 'linkid',
title: 'my link',
href: 'http://domain.com/page.html',
text: "linkk",
}).appendTo('#mydivid');
i would like to know this:
since the result is the same, which one is consider better to use as a coding standard?