3
I’m trying to create a plugin but I can’t catch the selector
, and it was even removed from version 1.9.
If I use $(this).selector
in the plugin, it returns a string #div #elementoA, #div #elementoB
. I’ve tried to use this.each
to try to pick up individually, but I couldn’t.
I need a way that returns either an array, or an object, but with the individual selectors: '[#div #elementoA] [#div #elementoB]
. It is possible using 1.9?
$('#div #elementoA, #div #elementoB').plugin()
The
each
would just try to grab the selector individually. I never created a plugin, what I am doing is a learning, but generally I call$('#div #A, #div #B').plugin()
and within the plugin I use.attr('id')
to work theCSS
. I’m certainly doing it wrong, so I wanted to try and catch theselector
. But I’ll try to learn better. Thanks for the answer.– Papa Charlie
A GAMB I did was give one
split
:$(this).selector.split( ', ' )
. Returned an array as wanted, but gambiarra is gambiarra right, never know... rs– Papa Charlie
@But what exactly do you need the dials for? If it is just for learning the split should work well, maybe with a more advanced regular expression become more reliable.
– utluiz
The selector
#div #elementoA
would give me the guarantee of only this element being manipulated. It is nothing complex, it is lack of knowledge even.– Papa Charlie
@Papacharlie Ever thought of counting the number of elements? Why is it important to ensure that only one element is being manipulated?
– utluiz
I put the links inside a
element
and in it I loop to catch each item. TKS– Papa Charlie