MediaWiki:Gadget-vector-headanchor.js

/** * Vector HeadAnchors * @author Krinkle, 2013 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-vector-headanchor.js */ ( function ( mw, $ ) {

$( '.mw-body .mw-headline' ).each( function ( i, el ) {		var id = el.id,			$headline = $( el ),			$header = $headline.parent;

if ( $header.find( '.mw-headline-anchor').length ) { return; }

$header.addClass( 'mw-header' ); $headline.removeAttr('id').wrap(			$( '' ).prop({ id: id, href: '#' + id, title: 'Link to this section', className: 'mw-headline-anchor' })		);	} );

}( mediaWiki, jQuery ) );