check this
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<select id="ddl"></select>
<script>
var json = [
{ parent: '1', item: 'Electronics' },
{ parent: '0', item: 'Play station' },
{ parent: '0', item: 'audios' },
{ parent: '1', item: 'Books' },
{ parent: '0', item: 'Non-Fiction' },
{ parent: '0', item: 'Maths' },
];
options = [];
var ddl = document.getElementById('ddl');
for (var i = 0; i < json.length; i++) {
var style = '', space = ' '
if (json[i].parent == '1')
{
style = "style='font-weight:bold'"
space =''
}
var html = "<option " + style + " > " + space + json[i].item; +" </option>"
options.push(html);
}
ddl.innerHTML = options.join('\n');
</script>
</body>
</html>
demo:
Edit fiddle - JSFiddle[
^]