[英]How can I change between arrow down and arrow up in a button?
How can I show arrow up symbol in a button? 如何在按钮中显示向上箭头符号? Respectively, I would like it to change when clicked to arrow down.
我想分别单击以向下箭头更改它。 How can I do that??
我怎样才能做到这一点??
I tried this but .... 我尝试了这个但是....
<button onclick="sortTable(1)" id="up_down" type="button" class="button button2">Sort table<i class="fa fa-fw fa-sort-asc"></i></button>
I am using the latest font awesome documentation, I could not see fa-sort-asc
so instead I use fa-sort-up
. 我正在使用最新的字体真棒文档,我看不到
fa-sort-asc
所以我改用fa-sort-up
。
function sortTable() {
const ascending = false; // change the value to your sorting method to check if it's ascending or descending.
const i = document.getElementById("up_down").getElementsByTagName("i")[0]
i.classList.remove("fa-sort-up", "fa-sort-down");
if (ascending) {
i.classList.add('fa-sort-up');
return;
}
i.classList.add('fa-sort-down');
}
Fiddle: https://jsfiddle.net/k6bxyps3/ 小提琴: https : //jsfiddle.net/k6bxyps3/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.