javascript - Add attribute to an object -


how can change attribute of tag in html code given object?

currently, if do:

console.log(gallery.curritem); 

i get:

so did:

console.log(gallery.curritem.html); 

and html in console (not object, believe it's texy):

<video width="500" height="250" controls><source src="" type=""></video> 

but i'm not sure how edit video tag adding attribute muted="muted".

i tried:

console.log($(gallery.curritem.html).find('video')); 

but returned object again. :/

i assume using photoswipe. gallery.curritem.html not string actual html element. can directly edit attributes of it:

gallery.curritem.html.setattribute("muted", "muted"); 

to make sure it's actual element, if in question, this:

if(gallery.curritem.html.tagname) {     gallery.curritem.html.setattribute("muted", "muted"); } else {     // append dom or wrap jquery , set attributes     gallery.curritem.html = $(gallery.curritem.html).attr("muted", "muted")[0]; } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -