Treehouse: Grow your CSS skills. Land your dream job.

JS Mouse location detect

  • Anonymous
    # July 16, 2013 at 9:15 pm

    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 :)))

    # July 17, 2013 at 9:18 am

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

    Here’s a pen that might help :: 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!

    # July 17, 2013 at 10:04 am

    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.

    # July 17, 2013 at 12:26 pm

    @Paulie_D I needed this

    # July 17, 2013 at 12:32 pm

    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?”.

    # July 17, 2013 at 6:31 pm

    @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)

You must be logged in to reply to this topic.