简体   繁体   中英

how to style the light dom of each instance of a polymer custom element independently using javascript

I will like to style the light dom's css using javascript from within the custom element's definition. Is it possible?

The premise is that I have a widget created using polymer, the content within the widget is declared in the light DOM. I like to be able to hide widget and the logic is scripted into the custom element itself.

Using this.children , we can access the elements within the light DOM of the instance of the custom element. It returns the elements as an array.

In my case, I wish to set the visibility of the elements within the light DOM to hidden when the widget is being minimized.

A for loop is used to set the visibility of all the elements within the light DOM

for(var i = 0;i<this.children.length;i++)
{
    $(this.children[i]).css("visibility",'hidden');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM