我会使用事件的选择器来放入我的函数,但它不起作用。
我已经尝试了一些技巧,我将在下面的代码中展示。
// the actual code
$('#voyages').on('click', function() {
if (continentOuvert == false) {
$('#voyages i.fas.fa-arrow-up').show(500);
$('#voyages i.fas.fa-arrow-down').hide();
}
});
// the functions I try to make
function arrowUp() {
$('this i.fas.fa-arrow-up').show(500);
$('this i.fas.fa-arrow-down').hide();
}
// or
function arrowUp() {
$(this + ' i.fas.fa-arrow-up').show(500);
$(this + ' i.fas.fa-arrow-down').hide();
}
什么也没发生,我想我没有做对。
感谢您的帮助。
最佳答案
您可以使用find
方法:
$(this).find('i.fas.fa-arrow-up').show(500);
$(this).find('i.fas.fa-arrow-down').hide();
关于javascript - 使用 'this' 关键字作为选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56236165/