gpt4 book ai didi

javascript - 如何在显示/隐藏按钮上的文本旁边显示图标?

转载 作者:行者123 更新时间:2023-11-30 11:02:39 25 4
gpt4 key购买 nike

<分区>

我想在单击 less/more 后在“more”和“less”旁边显示一个图标。

如何让多个按钮/id 像这样?基于检查的解决方案。 –

function showme(id) {
var divid = document.getElementById(id);
var clicky = document.getElementById("clicky");
if (divid.style.display == 'block') {
divid.style.display = 'none';
clicky.innerHTML = "MORE";
} else {
divid.style.display = 'block';
clicky.innerHTML = "LESS";
}
}
<!DOCTYPE html>
<html>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>

<body>
<i>Click on more. I want to have two different icons one for more one for less always after click.</i><br>

<div class="tp-caption rev-btn rev-hiddenicon rs-hover-ready rev-mre-btn" onclick="showme('widget');" href="javascript:;" id="clicky">MORE <i class="fa fa-car"></i></div>


<div id="widget" style="display:none;">
This is a widget
</div>


</body>

</html>

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com