- Web Dev Everyday
- Posts
- Web Dev Everyday - 5th September 2024 🖥️
Web Dev Everyday - 5th September 2024 🖥️
Daily dose of web dev
Welcome to Web Dev Everyday – your daily dose of 3 minute web development emails.
Let's dive in!
🎯 Tip of the day - 5 short Javascript tips!
Detect User’s Operating System
Get details about the user's OS platform using
navigator.platform
.
const OS = navigator.platform;
console.log(OS);
Prevent Page Refresh
Stop a link from refreshing the page with
javascript:void(0)
.
<a href="javascript:void(0);">Click me</a>
Validate Emails
Use a regular expression to verify email addresses.
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
console.log(emailPattern.test("[email protected]"));
Redirect Pages
Navigate to another page by changing
window.location.href
.
window.location.href = 'https://example.com';
Detect Mobile Browsers
Check if the user is on a mobile device with
navigator.userAgent
.
const isMobile = /Mobi|Android/i.test(navigator.userAgent);
console.log(isMobile);
Note: Those tips show some cool, native Javascript one-liners. It does not mean they are the best way to do stuff. For example for validations you might prefer using libraries such as zod
or yup
.
📰 Challenge - Pricing card
Design from: x.com/yahyabuilds
Brief: Build pricing card given the UI file.
Ideas to push it further:
Dynamic Pricing Animation: Animate the price on hover or when a discount is applied.
Interactive Hover Effects: Highlight the deliverables on hover with icons or subtle color changes.
Subscription Simulation: Add a toggle to compare monthly vs. yearly pricing.
Tooltips: Display additional information on features with tooltips.
Call to Action (CTA) Enhancement: Animate the "Get started" button on hover to increase engagement (example: border animation)