如何在这个 jQuery 选择器中放置一个动态属性?
我有这个对象..
$object = $(".service-box:first").attr("rel")
# => "spaghetti"
我试图在选择器中找到这个对象..
$(".hqs-text[rel=$object]")
但这是在此选择器中使用动态变量的不适当方法。
我怎样才能正确地做到这一点?
谢谢!!!
I have this object..
$object = $(".service-box:first").attr("rel")
# => "spaghetti"
I am trying to find the this object inside of a selector..
$(".hqs-text[rel=$object]")
But this is an innapropriate way to use dynamic variables in this selector.
How can I do this correctly?
Thanks!!!
简单的串联就可以了:
或者甚至都在一行中:
Simple concatenation will do:
Or even all in one line: