Why does my button's click event not register when the mouse pointer is in the spot shown in the screenshot below? I've created a jsFiddle for you to test it out. Make sure to check your browser's console for feedback.
http://jsfiddle.net/27kRH/
Here is my code, I'm using jQuery
var clickCounter = 0;
$('button').click(function(){
clickCounter++;
console.log('times clicked: ' + clickCounter);
});
Based on the above HTML and CSS, the clickable area will be the text only. Check the below figure: The correct way to do this is to add the padding on the link itself. Notice that the top and bottom padding won't work by default since it's an inline element.
Click areas are the clickable (or tappable) parts of links and buttons in your app. And they're probably making your users work harder than they need to.
To trigger a click button on ENTER key, We can use any of the keyup(), keydown() and keypress() events of jQuery. keyup(): This event occurs when a keyboard key is released. The method either triggers the keyup event, or to run a function when a keyup event occurs.
This issue is that a click is a mousedown + mouseup. When you click on that area, you are in the portion of a subelement on mousedown, but on mouseup you are in the portion of the parent element, so no element gets the full click. Not sure what the best way is to fix it, but that is the problem.
.logInBtn:active{
/*top:2.2em;*/
}
With that commented out it works.
I think Dave explained the problem well You are moving the element on its active state, moving the element on the active state is causing the mousedown to go to one element and the mouseup to go to another element, therefore, a click is not firing because the OS will only fire a click if the mouseup and mousedown are on the same element.
I think the best solution is to simplify your code a lot, and let the button handle the active state, you had styles that were affecting the active look of the button. The following CSS/HTML still has an active look and doesn't move the button from under your mouse, which is a bad idea from a UX perspective.
<button id="signUpLogIn-logInBtn" class="logInBtn">
<img src= "http://s10.postimg.org/z9yrvulut/log_In_Icon.png"/>
Add One<p class="logInBtnSub">See Console</p>
</button>
.logInBtn {
font-size: 1.4em;
text-transform: uppercase;
font-weight: 700;
background-color: #c6c6c6;
box-shadow: 0 8px #878787;
border-radius: 10px;
color: #402a3e;
cursor: pointer;
text-align: center;
}
.logInBtn img {
width: 50px;
height: 50px;
display: block;
margin: auto;
}
.logInBtnSub{
font-size: 0.6em;
color: #878787;
}
Here are a few workarounds
pointer-events: none
for elements within the button This works in the latest browsers I tested IE9, FF, and Chrome (credits to vals)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With