I’m trying to create a jQuery plugin and having problems with selecting the DOM.
for example, when I initialize the plugin (ex. $(‘#test’).customplugin();
this.each(function() {
// Var
var $this = $(this);
$this.hide();
var thisOpts = $( this + ' option');
$this.hide(); works as expected, hiding the element #test.
however, when I try to get for example the li of #test,
nothing seems to work.
Can someone help me understand what “this” exactly is,
and why “thisOpts” won’t target “#test option”?
Thanks!
What is “this”? Because if it’s not a string, you’re trying to append ” option” to an object.
Are you sure it shouldn’t be the following?