Adding an Element with Properties in jQuery Header

The other day I needed to add an element to a select using jQuery and because I can never remember the correct way to do this without making a huge mess so I’m documenting it here.

var select = $('#selectInQuestion');
var option = $("<option>", {
    'value':value,
    'label':label,
    'text':text
});
select.append(option);

Like this post? Don't forget to follow us on Twitter and Facebook for updates.