How can I detect onclick() or similar for individual characters in a text?

前端 未结 6 2165
你的背包
你的背包 2020-12-20 21:49

I\'m new to Javascript and would like to modify a text string by clicking on individual characters. The string is: 0000 0000 0000 0000 representing a binary num

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 22:08

    Maybe you can may be use coordinates of mouse when detect click: window.event.clientX and window.event.clientY gives you the X and Y coordinates of the mouse position.

    function SetValues()
    {
      var s = 'X=' + window.event.clientX + ' Y=' + window.event.clientY ;
      document.getElementById('divCoord').innerText = s;
    }
    

    and then you check the coordinates to fix the clicked text

提交回复
热议问题