horseatingweeds horseatingweeds - 4 years ago 188
Javascript Question

What is a JavaScript 'element' within the context of jQuery library OpenSeaDragon?

I'm using a pretty cool JavaScript/jQuery library called OpenSeaDragon. It's for displaying deep zoom images. It also have a method for adding 'overlays', essentially creating a div and putting it over the image with coordinates though a viewer object. There's also a method for removing the overlays:

viewer.removeOverlay(element or element id);

As the doc states regarding the input param: "A reference to the element or an element id which represent the ovelay content to be removed." I'm creating a whole bunch of overlays -- creating a grid out of rectangles -- so I've given them a class. Passing the class to this method doesn't work. So I'm trying to understand what they mean by "element". Is there a way I can use JQuery or JavaScript to select an "element" and pass it to the method? Or some such thing?


Answer Source

It usually means an element in your document, i.e. a DOM node. So, a div, or a span, or somesuch.

You can select an element with jQuery pretty easily:

var $obj = $('#elementId');

and then grab the underlying DOM node from the jQuery object that results:

var elm = $obj[0];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download