how to get focused element in jquery
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>focus demo</title>
<style>
.focused {
background: #abcdef;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<div id="content">
<input tabIndex="1">
<input tabIndex="2">
<select tabIndex="3">
<option>select menu</option>
</select>
<div tabIndex="4">
a div
</div>
</div>
<script>
$( "#content" ).delegate( "*", "focus blur", function() {
var elem = $( this );
setTimeout(function() {
elem.toggleClass( "focused", elem.is( ":focus" ) );
}, 0 );
});
</script>
</body>
</html>
Also in JavaScript:
- ejs
- onPress image react native
- jquery set hidden field value
- replace multiple spaces with single space javascript
- iterate over enum angular ngfor
- accept 2 values after decimal in angular forms
- button not clicking for random jokes in javascript
- jquery on body click
- how to bind a json output result to any new model
- javascript buttons
- loopback upsert
- uncheck checkbox when another is checked javascript
- foreach key value javascript
- select elements id like jquery
- repeat a function javascript
- jquery ajax CORS
- based on scroll position and get data attribute javascript
- if isset handlebars js
- stop a setinterval
- how to place text at custom position on canvas in javascript
- advanced data manipulation javascript
- javascript convert file to array
- $.post jquery beforesend loader
- remove second last element from array javascript