"This" in JS/jQuery

Hello,

I try to change the current interface in Xibo 1.8.0 and I need to use JavaScript/jQuery. But, it seems I can’t use $(this). In the console.log I have only a “window” object.

And for example, when I try to get the id of the current object by “console.log(this.id);” by click, I get an “undefined” entry in the console.

How can I get the “real” this ??

I am not sure why that would be, i’ve not had any issues with this before - what exactly are you trying to do?

I tried to change the sidebar for more lisibility by hiding sidebar-lists (css display none) and display expected list by clicking on the desired sidebarTitle.

In a new script when I try to get this by clicking on a sidebarTitle by console.log(this) or console.log($(this)) I can only get a window object.

So I can’t use $(this).next().toggle() for exemple to only display sidebarList after the choosen Title

I’m on the 1.8.0a2 release

Maybe a screenshot of what I want to do can be more expressiv.

If you run the below in the developer console:

$(".sidebar-title").click(function() { console.log(this); });

And then click on a side bar title, you get:

<li class="sidebar-title"><a>Design</a></li>

I think that is what you want?

Thank you, it works great !

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.