📄 Table of Contents

  • dynamically Add & Remove element with jQuery

Dynamically add and remove element with jQuery

Absolute File Paths


Relative File Paths

In the following example, the file path points to a file in the images folder located at the root of the current web:


Best Practice

It is best practice to use relative file paths (if possible).

When using relative file paths, your web pages will not be bound to your current base URL. All links will work on your own computer (localhost) as well as on your current public domain and your future public domains.

Event Handling on Buttons

<div class="buttons">
<button>Press 1</button>
<button>Press 2</button>
<button>Press 3</button>
const buttonContainer = document.querySelector('.buttons');
console.log('buttonContainer', buttonContainer);

buttonContainer.addEventListener('click', event => {

<input type="button" value="Start machine">
<p>The machine is stopped.</p>
const button = document.querySelector('input');
const paragraph = document.querySelector('p');

button.addEventListener('click', updateButton);

function updateButton() {
if (button.value === 'Start machine')
button.value = 'Stop machine';
paragraph.textContent = 'The machine has started!';
button.value = 'Start machine';
paragraph.textContent = 'The machine is stopped.';

Which ‘key’ has been clicked

$(‘#email-to-share’).keypress(function (e) {
var key =
if(key == 13){...}

The on() method attaches one or more event handlers for the selected elements.

mouseenter: function(){
$(this).css("background-color", "lightgray");
mouseleave: function(){
$(this).css("background-color", "lightblue");
click: function(){
$(this).css("background-color", "yellow");

Experience with Front-end Technologies and MERN / MEAN Stack. Working on all Major UI Frameworks like React, Angular.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store