为readmore下拉菜单添加图像

Add image for readmore drop down

本文关键字:图像 添加 下拉菜单 readmore      更新时间:2023-09-26

我想知道如何为这个脚本添加下拉图像。

 <a onclick="showMoreOrLess(this,'restOfArticle');">+Sign In </a>
 <span id="restOfArticle" style="display:none"> </span>
脚本

<script>function showMoreOrLess(thisObj, bonusContent) {
var caption = thisObj.innerHTML;
//alert(caption);
if (caption == "+Sign In") {
    document.getElementById(bonusContent).style.display = "inline";
    thisObj.innerHTML = "-Sign In";
} else {
    document.getElementById(bonusContent).style.display = "none";
    thisObj.innerHTML = "+Sign In";
}
}
</script>

我想用小图像图标代替+和-,怎么做?

删除+-符号。添加一个类到锚,然后使用:before伪选择器。

<a class="icon-left" onclick="showMoreOrLess(this,'restOfArticle');">Sign In </a>
CSS

.icon-left::before {
  content: url('Icon image URL here');
}