Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]')
- function focusable( element ) {
- var map, mapName, img,
- nodeName = element.nodeName.toLowerCase(),
- isTabIndexNotNaN = !isNaN( $.attr( element, "tabindex" ) );
- if ( "area" === nodeName ) {
- map = element.parentNode;
- mapName = map.name;
- if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
- return false;
- }
- img = $( "img[usemap=#" + mapName + "]" )[0];
- return !!img && visible( img );
- }
- return ( /input|select|textarea|button|object/.test( nodeName ) ?
- !element.disabled :
- "a" === nodeName ?
- element.href || isTabIndexNotNaN :
- isTabIndexNotNaN) &&
- // the element and all of its ancestors must be visible
- visible( element );
- function visible( element ) {
- return $.expr.filters.visible( element ) &&
- !$( element ).parents().addBack().filter(function() {
- return $.css( this, "visibility" ) === "hidden";
- }).length;
- }
- }
- $('*').each(function() {
- if(typeof this.focus == 'function') {
- // Do something with this element
- }
- }) ;
- $(document.body).on("focus", "*", function(e) {
- //Scroll to e.target
- });
- if ('focus' in element) {
- // element supports the foucs event
- }
- $('a[href], area[href], input, select, textarea, button, iframe, object, embed, *[tabindex], *[contenteditable]')
- .filter(':not([tabindex=-1]):not([disabled]):visible');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement