


Posted
in
by
Tags:
// Early exit if a skip-link target can't be located. if ( ! skipLinkTarget ) { return; }
/* * Get the site wrapper. * The skip-link will be injected in the beginning of it. */ sibling = document.querySelector( '.wp-site-blocks' );
// Early exit if the root element was not found. if ( ! sibling ) { return; }
// Get the skip-link target's ID, and generate one if it doesn't exist. skipLinkTargetID = skipLinkTarget.id; if ( ! skipLinkTargetID ) { skipLinkTargetID = 'wp--skip-link--target'; skipLinkTarget.id = skipLinkTargetID; }
// Create the skip link. skipLink = document.createElement( 'a' ); skipLink.classList.add( 'skip-link', 'screen-reader-text' ); skipLink.id = 'wp-skip-link'; skipLink.href = '#' + skipLinkTargetID; skipLink.innerText = 'Chuyển đến phần nội dung';
// Inject the skip link. sibling.parentElement.insertBefore( skipLink, sibling ); }() );