• 🌙 Community Spirit

    Ramadan Mubarak! To honor this month, Crax has paused NSFW categories. Wishing you peace and growth!

Code snippets plugins for HTML, CSS, and JS websites (1 Viewer)

Currently reading:
 Code snippets plugins for HTML, CSS, and JS websites (1 Viewer)

Recently searched:

testrest

Member
LV
1
Joined
Oct 19, 2022
Threads
11
Likes
3
Awards
4
Credits
1,067©
Cash
0$
Smooth Scroll Plugin:

This plugin adds smooth scrolling functionality to anchor links within the page.

document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); });


Image Lightbox Plugin:
This plugin enables a lightbox effect for images, allowing users to view them in a larger overlay without leaving the page.

document.querySelectorAll('.lightbox-image').forEach(image => { image.addEventListener('click', function () { // Open lightbox overlay and display clicked image }); });


Responsive Navigation Plugin:
This plugin creates a responsive navigation menu that collapses into a hamburger menu on smaller screens.

const menuButton = document.querySelector('.menu-button'); const navigation = document.querySelector('.navigation'); menuButton.addEventListener('click', function () { navigation.classList.toggle('active'); });


Form Validation Plugin:
This plugin provides client-side form validation, ensuring that user inputs meet specific criteria before submitting.

const form = document.querySelector('.form'); const emailInput = document.querySelector('#email'); form.addEventListener('submit', function (e) { if (!isEmailValid(emailInput.value)) { e.preventDefault(); // Display error message for invalid email } }); function isEmailValid(email) { // Validate email format return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); }


Scroll Reveal Plugin:
This plugin animates elements as they come into view while scrolling, adding a subtle and engaging effect.

document.addEventListener('scroll', function () { const elements = document.querySelectorAll('.scroll-reveal'); elements.forEach(element => { if (isElementInView(element)) { element.classList.add('visible'); } }); }); function isElementInView(element) { const rect = element.getBoundingClientRect(); return (rect.top >= 0 && rect.bottom <= window.innerHeight); }


Cookie Notice Plugin:
This plugin displays a notice at the top or bottom of the page to inform users about the use of cookies.

const cookieNotice = document.querySelector('.cookie-notice'); const acceptButton = document.querySelector('.accept-button'); acceptButton.addEventListener('click', function () { cookieNotice.classList.add('hidden'); // Set cookie to remember user's preference });

These code snippets demonstrate a variety of functionalities that can enhance the interactivity and user experience of a simple HTML, CSS, and JavaScript website.


Drop a like if it helps you.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Tips
Recently searched:

Similar threads

Users who are viewing this thread

Top Bottom