javascript - How can I manipulate css into a SVG -
javascript - How can I manipulate css into a SVG -
i'm trying improve code assigning css properly:
ischecked = jqelement.is(':checked'); type = jqelement.attr('tag'); var start = new date().gettime(); elements = document.getelementsbyclassname(type); console.log('layer ' + type + ': ' + elements.length); (j=0; j<elements.length; j++){ element = elements[j]; if (ischecked) element.classlist.remove('hide-layer'); else element.classlist.add('hide-layer'); //element.classname += ' hide-layer'; //element.classname = type; //element.setattribute('visibility', (ischecked)? '' : 'hidden'); }
using element.classname += ' hide-layer' doesn't work using element.classname += ' hide-layer' takes while (8 secons 1996 path elements same class)
the css class like:
.hide-layer{ visibility:hidden; }
hope can help me. in advance!
if set class on elements wanted hide manipulate class rule i.e. edit
.hide-layer{ visibility:hidden; }
to become
.hide-layer{ visibility:visible; }
you can access stylesheets via
document.stylesheets
if above rule rule in stylesheet page be
var rule = document.stylesheets[0].cssrules[0]
and
document.stylesheets[0].cssrules[0].style.setproperty('visibility','visible',null);
would update visibility property in rule.
javascript css svg
Comments
Post a Comment