javascript - Trigger a button with another button which is having the same value -
screenshot of problem described
i have 2 buttons different values i.e buttons values from. when open html file gets connected server on port 3000. when button in 1 file clicked button same value in tab or window should clicked. here have tried far
<script> var socket = io("http://localhost:3000"); socket.on('connect', function() { var x = document.getelementsbyname("sqr1")[0].value; x.addeventlistener("click", function () { socket.emit("clicked"); }); var y = document.getelementsbyname("sqr12")[0].value; y.addeventlistener("click", function () { socket.emit("clicked1"); }); }); socket.on('clicked', function() { var button1 = document.getelementbyid('sq1'); console.log('clicked'); document.getelementbyid("alert").innerhtml = "1 clicked"; onclickhandler(sq1); }); socket.on('clicked1', function() { var button2 = document.getelementbyid('sq2'); console.log('clicked1'); document.getelementbyid("alert").innerhtml = "2 clicked"; onclickhandler(sq2); }); </script>
Comments
Post a Comment