I want to programmatically create a selected HTML select
option
using Javascript (not jQuery).
What are the merits of creating it by setting the attributes as follows:
var option = document.createElement('option');
option.setAttribute('text', 'option1');
option.setAttribute('value', 5);
option.setAttribute("selected", true);
as opposed to setting properties:
var option = document.createElement('option');
option.text = 'option1';
option.value = 5;
option.selected = true;
I'd prefer to create the options using properties but just want to be sure that this isn't going to cause any issues, as many of the examples I've come across on the web tend to favour using the former approach (i.e. setting attributes).