如何将它与 JQuery 中的变量结合起来
How to combine this with variable in JQuery
脑子放屁了。我有这个代码:
$(function() {
$('#featured-top .option').click(function(){
$('#featured-top .option a').html('Close');
$('#featured-top .featured-content').slideToggle();
});
});
此行:
$('#featured-top .option a').html('Close');
我正在尝试使用这个:
$(this).html('Close');
但是如何使用选择器访问 link?我试过了:
$(this + 'a').html('Close');
但这不起作用。很简单,我知道,但不知为什么,我突然想不通了。
不,你不能那样做。您需要使用:
$('#featured-top .option').click(function(){
// Use this way:
$(this).find('a').html('Close');
// If you wanna change this as well, you can use:
$(this).closest("#featured-top").find('.featured-content').slideToggle();
});
脑子放屁了。我有这个代码:
$(function() {
$('#featured-top .option').click(function(){
$('#featured-top .option a').html('Close');
$('#featured-top .featured-content').slideToggle();
});
});
此行:
$('#featured-top .option a').html('Close');
我正在尝试使用这个:
$(this).html('Close');
但是如何使用选择器访问 link?我试过了:
$(this + 'a').html('Close');
但这不起作用。很简单,我知道,但不知为什么,我突然想不通了。
不,你不能那样做。您需要使用:
$('#featured-top .option').click(function(){
// Use this way:
$(this).find('a').html('Close');
// If you wanna change this as well, you can use:
$(this).closest("#featured-top").find('.featured-content').slideToggle();
});