Use <a> instead of <a href="#"> for JavaScript click events
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.jqueryMsg.js
index 44b9117..2646cff 100644 (file)
                        } else {
                                $el = $( '<a>' );
                                if ( typeof arg === 'function' ) {
-                                       $el.attr( 'href', '#' )
-                                       .click( function ( e ) {
-                                               e.preventDefault();
+                                       $el.attr( {
+                                               role: 'button',
+                                               tabindex: 0
                                        } )
-                                       .click( arg );
+                                       .on( 'click keypress', function ( e ) {
+                                               if (
+                                                       e.type === 'click' ||
+                                                       e.type === 'keypress' && e.which === 13
+                                               ) {
+                                                       arg.call( this, e );
+                                               }
+                                       } );
                                } else {
                                        $el.attr( 'href', textify( arg ) );
                                }