document.getElementById() alternatives

In the below we explain the JavaScript alternatives to getElementById() and show a working example of getElementById() together with two alternatives.  You can Scroll down and then click the buttons to read how the targets have been referenced.  Once we have the elements we apply some styles and add some text within our divs #target-1, #target-2 and #target-3 which you'll see when you click the buttons.

In our HTML code we have the following:

EU Cookie Compliance

This module addresses the General Data Protection Regulation (GDPR) that came into effect 25th May 2018, and the EU Directive on Privacy and Electronic Communications from 2012. It provides a GDPR cookie banner where you can gather consent from the user when the website stores cookies on their computer or otherwise handles their personal information.

Vertically centre and right align absolutely positioned child element in a flex container

Submitted by root on

.container_221 { display: flex; justify-content: center; align-items: center; position: relative; background: green; height: 100%; width: 100%; min-width: 250px; } .text_221 { position: absolute; background: red; padding: 12px; }

The referenced media source is missing and needs to be re-embedded.

 

webp

Creates a WebP copy of image style derivatives to decrease loading times.

Whenever an image style derivative is created this module will also create a WebP copy of the derivative to be served to supporting browsers.

301 Redirects for images (Rewrite)

An example is shown below.  This is within the .htaccess (htaccess) file.

  # To display the image that has been indexed on PINTREST
  # Redirecting old location to new location within Drupal
  # See: https://stackoverflow.com/questions/10871812/htaccess-image-redirection-for-specific-images-on-one-to-one-basis

  RewriteRule ^images/Island_Corian_Worktop_Iso_sm.jpg$ https://www.solidity.co.uk/sites/default/files/images/Island_Corian_Worktop_Iso_sm.jpg [L,R=301]