Can someone explain to me, why calling the focus() method on an element, triggers that elements keyup event, when the focus() method is called from an click event handler, but that handler is triggered by a keypress? Above is an example, that you can try out yourself. The expexted behaviour for me is, that when clicking or hitting enter on
Tag: focus
How can i set focus on a newly (automatically) rendered dom element?
I have an input field that gets replaced automatically with a textarea and same content depending on the number of characters the user has entered: The problem i have is that the focus gets lost when a user enters the 21st character. And thus the user gets irritated because when he types the 22nd character it does not appear in
Can’t fully reset activeElement (focus for the Tab key) to its default position
OK, I’m trying to reset the activeElement from the middle of the page so that the tab key would start from the top like, the same way as the page is just refreshed. For that purpose (tested in FF and Chrome) I’m trying to use document.activeElement.blur() (from the browser console). As result, the selection of the <a href></a> gets visually
Focus trap for multiple modals
I’m working on a trap focus modal functionality and it works well with a single element, but I can’t get it working with multiple elements. It traps focus only on last modal. I know there is something wrong with my loop, I tried to catch activeElement and add a condition if it’s equal to focused element but with no result.
How to set focus on an input that works on IOS supporting devices?
My aim is to set focus on an input via the button click method. I used a template variable, but doing it via component code seems to give the same result. This works as expected on all devices where I tested (MacBook and some mobile devices) whatever the browser is, i.e. Safari, Chrome, Firefox, however it doesn’t work on iOS
Detect which form input has focus using JavaScript or jQuery
How do you detect which form input has focus using JavaScript or jQuery? From within a function I want to be able to determine which form input has focus. I’d like to be able to do this in straight JavaScript and/or jQuery. Answer I am not sure if this is the most efficient way, but you could try: