我在以下元素上有一个点击功能:
$('#make article > a, #latestInner article > a').click(function (e) {...});
现在我想将上面的点击绑定到以下内容:
$('#make article h4 a, #latestInner article h4 a, #models article h4 a').click(function (e) {...});
以便点击:
#make article > a, #latestInner article > a
就好像我点击了:
#make article h4 a, #latestInner article h4 a, #models article h4 a
答案 0 :(得分:2)
jQuery的trigger()
会这样做:
$('#make article > a, #latestInner article > a').click(function() {
$('#make, #latestInner, #models').find('article h4 a').trigger('click');
});
答案 1 :(得分:1)
$('#make article > a, #latestInner article > a').click(function (e) {
("#make article h4 a").trigger('click');
}
答案 2 :(得分:0)
试试这个:
$('#make article > a, #latestInner article > a').click(function (e) {
$('#make article h4 a').click();
$('#latestInner article h4 a').click();
$('#models article h4 a').click();
});
$('#make article h4 a, #latestInner article h4 a, #models article h4 a').click(function (e) {...});
希望有所帮助:)