将变量与 jquery 选择器一起使用
using variable with jquery selector
我有以下几行代码,我想使用 visibleoffer
变量作为选择器。我怎样才能连接它?
var visibleoffer = '.' + obj.parents('tbody').attr('providername') + ' .visible-offers'; //visibleoffer = .Txy .visible-offers
$(obj).parents('.Provider').find(".Offers:not(.HideByProviderFilter,.HideByMainFilter,.HideByProviderFilter.HideByMainFilter,+ visibleoffer)").length;
所以变成:
$(obj).parents('.Provider').find(".Offers:not(.HideByProviderFilter,.HideByMainFilter,.HideByProviderFilter.HideByMainFilter,.Txy .visible-offers)").length;
您需要在构建选择器字符串时连接变量:
$(obj).parents('.Provider').find(".Offers:not(.HideByProviderFilter,.HideByMainFilter,.HideByProviderFilter.HideByMainFilter," + visibleoffer +")").length;
我有以下几行代码,我想使用 visibleoffer
变量作为选择器。我怎样才能连接它?
var visibleoffer = '.' + obj.parents('tbody').attr('providername') + ' .visible-offers'; //visibleoffer = .Txy .visible-offers
$(obj).parents('.Provider').find(".Offers:not(.HideByProviderFilter,.HideByMainFilter,.HideByProviderFilter.HideByMainFilter,+ visibleoffer)").length;
所以变成:
$(obj).parents('.Provider').find(".Offers:not(.HideByProviderFilter,.HideByMainFilter,.HideByProviderFilter.HideByMainFilter,.Txy .visible-offers)").length;
您需要在构建选择器字符串时连接变量:
$(obj).parents('.Provider').find(".Offers:not(.HideByProviderFilter,.HideByMainFilter,.HideByProviderFilter.HideByMainFilter," + visibleoffer +")").length;