Bryce
Bryce

Reputation: 47

Adding a picture in javascript

Okay so I have a menu with names of transmissions. I'd like to add a small little transmission logo beside each tab. This is the code that I would like to add on to:

document.getElementById("nav02").innerHTML =
"<ul id='menu'>" +
(RIGHT HERE IS WHERE ID LIKE THE LOGO TO APPEAR, I AM NOT SURE IF THIS IS WHERE THE CODE WOULD GO EITHER)"<li><a href='32RH.html'>32RH</a></li>" +
"<li><a href='Build.html'>36RH</a></li>" +
"<li><a href='Customers.html'>42RH</a></li>" +
"<li><a href='About.html'>42RE</a></li>" +
"</ul>";

Upvotes: 0

Views: 78

Answers (1)

thedouglenz
thedouglenz

Reputation: 514

You just need to use the list-style-image CSS property. http://www.w3schools.com/cssref/pr_list-style-image.asp

You can add this to your file somewhere in the head:

<style type="text/css">
    ul { list-style-image: url('images/transmission-logo'); }
</style>

If you want to do it right in the JavaScript:

    document.getElementById("menu").style.listStyleImage="url('images/transmission-logo')";

Upvotes: 2

Related Questions