Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在插件中获取目标元素类名称或 id 名称?
例如,
$('.class').pluginname(); $('#mymyid').pluginname();
我想得到'.myclass'和'#myid'
'.myclass'
'#myid'
是否可以?
谢谢。
我认为您需要使用选择器属性。例如:
$('.class').selector
我认为这是不可能的,除非你明确地将它作为参数传递给插件,因为如果你有一个 DOM 元素列表(这是你在插件中拥有的)你不知道哪个选择器用于获取那些元素,可能有不同的方法和选择器来获取相同的 DOM 元素集。