[英]change style list image onclick + to -
Hello everybody I hope you are all fine please help me to resolve this problem,I am confused with this, when "onclick" I want that the + become - like this attached image. 大家好,我希望你一切都好,请帮助我解决这个问题,对此我感到困惑,当“ onclick”时我希望+变成-像下面的图片。 remember that that + and - are images named image 'puceplus.png' and 'pucemoins.png'
请记住,+和-是分别名为image'puceplus.png'和'pucemoins.png'的图像
#ulist li:before {
content: url('puceplus.png');
margin-right: 4px;
}
<ul id="ulist">
<li onclick="hideshow('usublist1')">
Gestion des données clients
<ul id="usublist1" style="display:none;" class="sublist">
<li >
Centraliser vos données clients et éviter les redondances
</li>
</ul>
</li>
</ul>
I would use two different classes for opened and closed status. 我将为打开和关闭状态使用两个不同的类。 Then with javascript you changed that on click.
然后使用javascript,您可以在点击时进行更改。
There is a working example without jQuery. 有一个没有jQuery的有效示例。 You just have to include your images in the right places (content:url(...)).
您只需将图像包含在正确的位置(content:url(...))。
jsfiddle: change style list image without jQuery jsfiddle:在不使用jQuery的情况下更改样式列表图像
#ulist > li {
list-style: none;
}
#ulist > li:hover {
cursor: pointer;
}
#ulist > li:before {
margin-right: 4px;
}
#ulist > li.closed:before {
content: "+";
}
#ulist > li.opened:before {
content: "-";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.