+ 4

Question regarding html #2.

How to toggle onmouseover in svg and how to set multiple value in the same option like radius fill stroke etc.

11th Jun 2017, 6:55 AM
RZK 022
RZK 022 - avatar
1 Antwort
+ 5
What do you mean by "toggle onmouseover"? @@ And do you have always a question? As you seems know how to use events with svg attributes: https://code.sololearn.com/WpvtPesM3I60/?ref=app If your difficulty is to set many attributs for each event, simply separate the different JS instructions by the semi-coma (;) and a space (for readability :P): onmouseover="evt.target.setAttribute('fill', 'red'); evt.target.setAttribute('r', '75');" Obviously, this could become hard to read/write if you have a lot of JS to execute for an event listener... so a more clean solution (not already completly) is to define a function elsewhere (in a <script> section, inlined or linked) to be called in the event attribute: onmouseover="myfunc2handleover(evt);" And elsewhere: <script> function myfunc2handleover(e) { e.target.setAttribute('fill', 'red'); e.target.setAttribute('r', '75'); /* any complex code call */ } </script> Anyway, the cleanest way to handle events (some are only accessible by this way) is to use the addEventListener() method to attach functions ^^
12th Jun 2017, 2:03 AM
visph
visph - avatar