\u00a0<\/p>","post":"","numboards":1,"description":"It is possible to supply user-defined defined functions for certain events. The user-defined functions are called additionally to the default JSXGraph events. For the events `down` and `up` the user-supplied event handlers are called before the default JSXGraph event handler. For the event `update` the user-supplied handler is called after the default JSXGraph event handler which is an update of the board.\n\nA user-supplied event handler can be defined by the method `on`:\n\n~~~\n var p = board.create('point',[1,1]);\n p.on('update', function(e) { \/* do something ... *\/);\n~~~\n\nThe possible events are listed in the API docs for [elements, see Event Summary](https:\/\/jsxgraph.org\/docs\/symbols\/JXG.GeometryElement.html) and\n[board, see Event Summary](https:\/\/jsxgraph.org\/docs\/symbols\/JXG.Board.html).\n\nAs of version 1.5.0, it is only possible to access the element via *this* if the event listener is supplied as regular JavaScript function and not as *arrow function*.","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 12:27:09","visible":1,"tags":[{"id":130,"alias":"technical","name":"Technical"}],"tag_ids":[130],"refers_to":[],"refers_to_ids":[],"authors":[],"authors_ids":[],"unique_ids":["jxgbox-6753cf4514c5a"],"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});\n\nvar p = board.create('point', [1, 1], {\n size: 5,\n fixed: true\n});\np.on('over', (e) => {\n document.getElementById('myOutput').innerHTML = \"Point \" + p.name;\n});\n\np.on('out', (e) => {\n document.getElementById('myOutput').innerHTML = '\u00a0';\n});\n\nvar p2 = board.create('point', [-1, 1], {\n size: 5\n});\np2.on('over', function(e) {\n document.getElementById('myOutput').innerHTML = \"Point \" + this.name;\n});\np2.on('out', function(e) {\n document.getElementById('myOutput').innerHTML = '\u00a0';\n});","code_execute_html":"
<iframe src="https://jsxgraph.org/share/iframe/adding-jsxgraph-events" style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" name="JSXGraph example: Adding JSXGraph events" 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, fixed: true }); p.on('over', (e) => { document.getElementById('myOutput').innerHTML = "Point " + p.name; }); p.on('out', (e) => { document.getElementById('myOutput').innerHTML = ' '; }); var p2 = board.create('point', [-1, 1], { size: 5 }); p2.on('over', function(e) { document.getElementById('myOutput').innerHTML = "Point " + this.name; }); p2.on('out', function(e) { document.getElementById('myOutput').innerHTML = ' '; }); </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, fixed: true }); p.on('over', (e) => { document.getElementById('myOutput').innerHTML = "Point " + p.name; }); p.on('out', (e) => { document.getElementById('myOutput').innerHTML = ' '; }); var p2 = board.create('point', [-1, 1], { size: 5 }); p2.on('over', function(e) { document.getElementById('myOutput').innerHTML = "Point " + this.name; }); p2.on('out', function(e) { document.getElementById('myOutput').innerHTML = ' '; });
<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, fixed: true }); p.on('over', (e) => { document.getElementById('myOutput').innerHTML = "Point " + p.name; }); p.on('out', (e) => { document.getElementById('myOutput').innerHTML = ' '; }); var p2 = board.create('point', [-1, 1], { size: 5 }); p2.on('over', function(e) { document.getElementById('myOutput').innerHTML = "Point " + this.name; }); p2.on('out', function(e) { document.getElementById('myOutput').innerHTML = ' '; });
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.