Hi Bader,

bader houmad wrote:

I want to change the attributes of an element, but not all of them: (ex: myElement is a rectangle, "fill:BLACK" "stroke:RED"and "stroke-width:15")

myElement.setAttributeNS(null,"style", "fill:BLUE");

You have a couple of options here. One is to use presentation attributes. So instead of saying: style="fill:black; stroke:red; stroke-width:15" Use: fill="black" stroke="red" stroke-width="15"

  Then you can use: myElement.setAttributeNS(null, "fill", "blue")

this way myRectangle becomes BLUE but its stroke is set by default to black and stroke-width to zero.

is there a method to change only the "fill" for example?

The other option is to use the CSSStyleDeclaration:

   myElement.getStyle().setProperty("fill", "blue", "");

   The last parameter can be "!important" to make the
property specification 'important' as per the CSS specification.

   HTH

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to