• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / Archives for JavaScript

JavaScript

How to make the font-weight bold of the first word with JS?

View Demo

1) Add the class firstWord to your heading or paragraph

2) You can select the first word of the text by adding a span class to it with jQuery

Filed Under: JavaScript Tagged With: jQuery

Parallax Effect with Vanilla JavaScript

HTML

CSS

JavaScript

Filed Under: JavaScript Tagged With: Parallax

Simple Bar – Scroll Bar

DEMO

HTML

CSS

.demo1 {
     height: 380px;
     max-width: 100%;
 }

If you want to use in WordPress just enqueue the simplebar library in functions.php

Filed Under: JavaScript Tagged With: SimpleBar

Get videos from channel by YouTube Data API

Filed Under: JavaScript Tagged With: API

jQuery – Add class only to the selected item

$(document).ready(function () {
   $('button').click(function () {
     $("button").removeClass("selected");
     $(this).addClass("selected");
   });
 });

Filed Under: JavaScript Tagged With: jQuery

jQuery – Do something if checkbox is checked

Filed Under: JavaScript Tagged With: jQuery

jQuery Changing Element Styles and Classes

Filed Under: JavaScript Tagged With: jQuery

jQuery fadeOut on scroll

jQuery(document).ready(function(){
   jQuery(window).scroll(function(){
         if(jQuery(this).scrollTop() > 600){
             jQuery('#').fadeOut();
         }
         else{
             jQuery('#').fadeIn();
         }
     });
 });

Filed Under: JavaScript Tagged With: jQuery

Add class with jQuery when scrolling

jQuery(window).scroll(function () {
       if (jQuery(document).scrollTop() > 1 ) {
         jQuery('.cube-desktop').addClass('show');
       } else {
         jQuery('.cube-desktop').removeClass('show');
       }
 });    

Filed Under: JavaScript Tagged With: jQuery

Remove only the clicked list item from unordered list – parentNode

const toggleList = document.getElementById('toggleList');
const listDiv = document.querySelector('.list');
const descriptionInput = document.querySelector('input.description');
const descriptionP = document.querySelector('p.description');
const descriptionButton = document.querySelector('button.description');
const listUl = listDiv.querySelector('ul');
const addItemInput = document.querySelector('input.addItemInput');
const addItemButton = document.querySelector('button.addItemButton');
listUl.addEventListener('click', (event) => {
   if (event.target.tagName == 'BUTTON') {
     let li = event.target.parentNode;
     let ul = li.parentNode;
     ul.removeChild(li);
   }
 });
 toggleList.addEventListener('click', () => {
   if (listDiv.style.display == 'none') {
     toggleList.textContent = 'Hide list';
     listDiv.style.display = 'block';
   } else {
     toggleList.textContent = 'Show list';                        
     listDiv.style.display = 'none';
   }                         
 });
 descriptionButton.addEventListener('click', () => {
   descriptionP.innerHTML = descriptionInput.value + ':';
   descriptionInput.value = '';
 });
 addItemButton.addEventListener('click', () => {
   let ul = document.getElementsByTagName('ul')[0];
   let li = document.createElement('li');
   li.textContent = addItemInput.value;
   ul.appendChild(li);
   addItemInput.value = '';
 });

Filed Under: JavaScript Tagged With: DOM

  • « Go to Previous Page
  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Go to Next Page »

Primary Sidebar

  • angular.io
© 2026 WP Flames - All Right Reserved