gpt4 book ai didi

javascript - 检查是否单击了特定标签

转载 作者:行者123 更新时间:2023-11-29 17:21:19 25 4
gpt4 key购买 nike

我该怎么做:

var izbor = $('.kategorija_izbor ul a'),
mgl = $(".mali_oglasi"),
pretraga = $('.mali_oglas a[role=pretraga]'),
article = $('.mali_oglasi article'),
mgl_wrapper = $('.mali_oglasi_wrapper');

(pretraga || izbor).on('click', function(e) {
var id = $(this).attr('href').split('/'),
mgl_space = $(this).attr('href').replace(/\s+/g, '-').toLowerCase();
link = mgl_space + ' .mali_oglasi';
mgl.animate({
'opacity': 0
}, 400, function() {
mgl_wrapper.load(link, function() {
mgl.animate({
'opacity': 1
}, 400);
});
});
e.preventDefault();
});​

我需要查看是否按下了 pretragaizbor。这种方式行不通。有办法实现吗?

最佳答案

or 运算符不能用于引用两个变量实例。

您要做的是将函数绑定(bind)到多个 jQuery 对象:

$('.kategorija_izbor ul a, .mali_oglas a[role=pretraga]').on('click',
function(e) {
var id = $(this).attr('href').split('/'),
mgl_space = $(this).attr('href').replace(/\s+/g, '-').toLowerCase();
link = mgl_space + ' .mali_oglasi';
mgl.animate({
'opacity': 0
}, 400, function() {
mgl_wrapper.load(link, function() {
mgl.animate({
'opacity': 1
}, 400);
});
});
e.preventDefault();
});​

关于javascript - 检查是否单击了特定标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12647115/

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