<\/p>\n","post":"","numboards":1,"description":"*Please note:* Adding generic DOM events works only if SVG renderer is used. Nearly all JSXGraph elements have a subobject `rendNode` which is a pointer to its SVG element in the DOM. This element can be supplied with event listeners.","dimensions":[{"width":"100%","height":"","aspect-ratio":"1 \/ 1"}],"wider":0,"license":{"id":1,"identifier":"CC BY 4.0","title":"Creative Commons Attribution 4.0 International","free":"- Share\r\n- Adapt","restrictions":"- Attribution\r\n- No additional restrictions","with_attribution":1,"link":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/","image":"https:\/\/i.creativecommons.org\/l\/by\/4.0\/88x31.png","rank":0},"timestamp":"2023-01-23 11:34:05","visible":1,"tags":[{"id":133,"alias":"jsxgraph-objects","name":"JSXGraph objects"}],"tag_ids":[133],"refers_to":[],"refers_to_ids":[],"authors":[],"authors_ids":[],"unique_ids":["jxgbox-673f2b4b36fd5"],"code_display":"\/\/ Define the id of your board in BOARDID\n\nconst board = JXG.JSXGraph.initBoard(BOARDID, {\n boundingbox: [-4, 4, 4, -4],\n keepaspectratio: true\n});\nvar p = board.create('point', [1, 1], {\n size: 5\n});\n\nJXG.addEvent(p.rendNode, 'mouseover',\n function() {\n document.getElementById('myOutput').innerHTML = \"Point \" + this.name;\n },\n p);\nJXG.addEvent(p.rendNode, 'mouseout',\n function() {\n document.getElementById('myOutput').innerHTML = ' ';\n },\n p);\n\n\/\/ User can not move \"A\" anymore.\np.hasPoint = function() {\n return false;\n};\n\nvar p2 = board.create('point', [-1, 1], {\n size: 5\n});\n\nJXG.addEvent(p2.rendNode, 'mouseover',\n function() {\n document.getElementById('myOutput').innerHTML = \"Point \" + this.name;\n },\n p2);\n\nJXG.addEvent(p2.rendNode, 'mouseout',\n function() {\n document.getElementById('myOutput').innerHTML = ' ';\n },\n p2);","code_execute_html":"
<iframe src="http://jsxgraph.org/share/iframe/add-generic-dom-events-to-jsxgraph-elements" style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" name="JSXGraph example: Add generic DOM events to JSXGraph elements" allowfullscreen ></iframe>
<p id="myOutput"> </p> <div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; "> <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div> </div> <script type = "text/javascript"> /* This example is licensed under a Creative Commons Attribution 4.0 International License. https://creativecommons.org/licenses/by/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'board-0'; const board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-4, 4, 4, -4], keepaspectratio: true }); var p = board.create('point', [1, 1], { size: 5 }); JXG.addEvent(p.rendNode, 'mouseover', function() { document.getElementById('myOutput').innerHTML = "Point " + this.name; }, p); JXG.addEvent(p.rendNode, 'mouseout', function() { document.getElementById('myOutput').innerHTML = ' '; }, p); // User can not move "A" anymore. p.hasPoint = function() { return false; }; var p2 = board.create('point', [-1, 1], { size: 5 }); JXG.addEvent(p2.rendNode, 'mouseover', function() { document.getElementById('myOutput').innerHTML = "Point " + this.name; }, p2); JXG.addEvent(p2.rendNode, 'mouseout', function() { document.getElementById('myOutput').innerHTML = ' '; }, p2); </script>
/* This example is licensed under a Creative Commons Attribution 4.0 International License. https://creativecommons.org/licenses/by/4.0/ Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits. */ const BOARDID = 'your_div_id'; // Insert your id here! const board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-4, 4, 4, -4], keepaspectratio: true }); var p = board.create('point', [1, 1], { size: 5 }); JXG.addEvent(p.rendNode, 'mouseover', function() { document.getElementById('myOutput').innerHTML = "Point " + this.name; }, p); JXG.addEvent(p.rendNode, 'mouseout', function() { document.getElementById('myOutput').innerHTML = ' '; }, p); // User can not move "A" anymore. p.hasPoint = function() { return false; }; var p2 = board.create('point', [-1, 1], { size: 5 }); JXG.addEvent(p2.rendNode, 'mouseover', function() { document.getElementById('myOutput').innerHTML = "Point " + this.name; }, p2); JXG.addEvent(p2.rendNode, 'mouseout', function() { document.getElementById('myOutput').innerHTML = ' '; }, p2);
<p id="myOutput"> </p>
// Define the id of your board in BOARDID const board = JXG.JSXGraph.initBoard(BOARDID, { boundingbox: [-4, 4, 4, -4], keepaspectratio: true }); var p = board.create('point', [1, 1], { size: 5 }); JXG.addEvent(p.rendNode, 'mouseover', function() { document.getElementById('myOutput').innerHTML = "Point " + this.name; }, p); JXG.addEvent(p.rendNode, 'mouseout', function() { document.getElementById('myOutput').innerHTML = ' '; }, p); // User can not move "A" anymore. p.hasPoint = function() { return false; }; var p2 = board.create('point', [-1, 1], { size: 5 }); JXG.addEvent(p2.rendNode, 'mouseover', function() { document.getElementById('myOutput').innerHTML = "Point " + this.name; }, p2); JXG.addEvent(p2.rendNode, 'mouseout', function() { document.getElementById('myOutput').innerHTML = ' '; }, p2);
This example is licensed under a Creative Commons Attribution 4.0 International License. Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.