Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript JS Mouse location detect

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #46461
    Anonymous
    Inactive

    For example: my div’s width is 100% and I want to click this div, when I click in 40% or 60% I need detect this number, where is mouse location and count this width :)))

    #143317
    Eric Gregoire
    Participant

    Could you just put another div inside at the size you need and assign a click event?

    Here’s a pen that might help :: http://codepen.io/Boogiesox/pen/BrCeD it gets coords relative to a targeted element (perhaps your 40% or 60% element if possible).

    Otherwise, please provide an example or try and explain more thoroughly. Thanks!

    #143328
    Paulie_D
    Member

    We don’t know what he intends to do once the width is calculated so I’m not sure how an extra element (which may or may not be there in the first place).

    As a rule of thumb, my first question to the OP is..

    **”What are you trying to do and why?”**

    Quite often they are trying to go about something completely the wrong way. This may not be true in this case but without further information it’s hard to offer advice.

    #143367
    Anonymous
    Inactive
    #143374
    Paulie_D
    Member

    So this is solved?

    I get that the Codepen gives you the information, my question is “now what are you going to do with it?”.

    #143417
    Anonymous
    Inactive

    @Paulie_D Yes, this is solved. I wanted this for a make custom range input, with value and steps . . .

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.