I’m creating an option in a select element and trying to change the background image.
nextItem = document.createElement('option');
nextItem.innerHTML = text;
nextItem.style.backgroundImage = "url(icons/add.png);";
nextItem.className = "class1";
When I use firebug, however, I can see that what actually gets created is this:
<option class="class1" style="">text</option>
Why is it creating the the style attribute but not putting any information in it?
Remove the semi-colon in the url.
Change:
to:
jsFiddle example