javascript - Accessing element attributes of "Object #<HTMLDivElement>" -


i can't figure out - i'm trying retrieve attribute of active slide in royalslider. managed active slide's html content in htmldivelement object. in chrome's console shows tree view of html element want , children. want access either id of element or own custom attribute, error keep getting is:

uncaught typeerror: object #<htmldivelement> has no method 'attr' 

this line outputs it:

console.log(jquery('.royalslider').data('royalslider').currslide.content.first()[0].attr("id")); 

i know need use jquery('.royalslider').data('royalslider').currslide.content don't know rest. how can access custom attribute slideid?

in statement:

console.log(jquery('.royalslider').data('royalslider').currslide.content.first()[0].attr("id")); 

the [0] gives access html dom object (using jquery get() method), not jquery version of it. rid of [0] , should able call attr.

so following should work:

console.log(jquery('.royalslider').data('royalslider').currslide.content.first().attr("id")); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -