The following code:
<Div id = 'nav' class = 'nav'> <ul> <li> homepage </li> </ul> </div>
Use. nav ul li {background: url (../img/bg. jgp);} After Definition
This style. nav_ul_li_1 {background: url (../img/bg1.jpg );}}
You cannot use document. getElementById ('nav'). className = 'nav _ ul_li_1 ';
To change the background and background color.
The solution is to define the background () using the general method ul li :();
Correct the information as follows:
<Div class = 'nav'> <ul> <li id = 'nav'> homepage </li> </ul> </div>
Thank you for choosing style. backgroundImage, but className does not work.
The Code is as follows: <Head>
<Title> a conflict between css and javascript </title>
<Style type = "text/css">
. Nav ul li {background: url(bg.jpg) no-repeat 5px 5px; width: 100px; height: 30px; float: left ;}
</Style>
<Script type = "text/javascript">
Function f (obj ){
Obj. style. backgroundImage = 'url(bg1.jpg )';
}
</Script>
</Head>
<Body>
<Div class = 'nav'>
<Ul>
<Li onmouseover = 'f (this); '> homepage </li>
<Li> Contact Us </li>
</Ul>
</Div>
</Body>
</Html>