shubh - HTMLify profile

shubh
87 Files
18952 Views
Latest files of /shubh/javascript
//DOM Manipulation in JS...
// Selecting With id
document.getElementById("myId");
// Selecting With class
document.getElementByClassName("className");
// Selecting With tag
// Selecting With id
document.getElementById("myId");
// Selecting With class
document.getElementByClassName("className");
// Selecting With tag
//String Methods
//str.toUpperCase()
let str="Shubh";
console.log(str.toUpperCase());
//str.toLowerCase()
let str="Shubh";
console.log(str.toLowerCase());
//str.toUpperCase()
let str="Shubh";
console.log(str.toUpperCase());
//str.toLowerCase()
let str="Shubh";
console.log(str.toLowerCase());
// DOM Manipulation
// innerText properties
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
// innerText properties
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
// Toggle Button to switch light theme to dark..
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Toggle Button</title>
<style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Toggle Button</title>
<style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>events</title>
body {
margin: 0;
padding: 0;
background: linear-gradient(120deg, rgb(10, 10, 208), rgb(246, 3, 3));
background-repeat: no-repeat;
background-size: cover;
height: 100vh;
}
margin: 0;
padding: 0;
background: linear-gradient(120deg, rgb(10, 10, 208), rgb(246, 3, 3));
background-repeat: no-repeat;
background-size: cover;
height: 100vh;
}
//Here the examples of object in JavaScript..
const profile={
username:"Shubh Kulshrestha",
posts:1,
followers:85,
following:157,
};
console.log(profile);
const profile={
username:"Shubh Kulshrestha",
posts:1,
followers:85,
following:157,
};
console.log(profile);
// getAttribute
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Properties</title>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Properties</title>
// node.Style
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Properties</title>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Properties</title>
// Operators in JavaScript...
// Arithmetic Operator
let a = 10;
let b = 5;
console.log(a + b); // Addition
console.log(a - b); // Subtraction
console.log(a * b); // Multiplication
console.log(a / b); // Division
// Arithmetic Operator
let a = 10;
let b = 5;
console.log(a + b); // Addition
console.log(a - b); // Subtraction
console.log(a * b); // Multiplication
console.log(a / b); // Division
//Loops in Javascript...
//For loop
for (let i = 1; i <= 5; i++){
console.log("Hello JavaScript..");
}
//Calculate sum of n numbers...
let num = prompt("Enter the number:");
//For loop
for (let i = 1; i <= 5; i++){
console.log("Hello JavaScript..");
}
//Calculate sum of n numbers...
let num = prompt("Enter the number:");
// delete element
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>delete element</title>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>delete element</title>
// ondblclick event using inline event handling
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>events</title>
<style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>events</title>
<style>
// setAttribute
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Properties</title>
<style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Properties</title>
<style>
//insert element
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>insert element</title>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>insert element</title>
// Event Object
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>event object</title>
<style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>event object</title>
<style>
//Events in JavaScript...
//Event Handling...
node.event = () =>{
// handle here
};
//Event objects
Node.event = (e) =>{
//Event Handling...
node.event = () =>{
// handle here
};
//Event objects
Node.event = (e) =>{
// Arrays in JavaScript...
let marks=[23,45,67,43,76];
console.log(marks);
console.log(marks.length);// Arrays length
//Looping over an array...
let marks=[23,45,67,43,76];
for(i=0;i<marks.length;i++){
let marks=[23,45,67,43,76];
console.log(marks);
console.log(marks.length);// Arrays length
//Looping over an array...
let marks=[23,45,67,43,76];
for(i=0;i<marks.length;i++){
// Template Literals
let userName=prompt("enter name: ");
let fullName=`@${userName}${userName.length}`;
console.log(fullName);
let userName=prompt("enter name: ");
let fullName=`@${userName}${userName.length}`;
console.log(fullName);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Properties</title>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Properties</title>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OTP Generator</title>
<link rel="stylesheet" href="OTP.css">
</head>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OTP Generator</title>
<link rel="stylesheet" href="OTP.css">
</head>
function generateOTP(){
let otp = " ";
let digits = "0123456789";
for(i=0;i<4;i++){
otp += digits [Math.floor(Math.random()*10)];
}
document.getElementById("otpdisplay").innerText=`OTP is ${otp}`;
}
let otp = " ";
let digits = "0123456789";
for(i=0;i<4;i++){
otp += digits [Math.floor(Math.random()*10)];
}
document.getElementById("otpdisplay").innerText=`OTP is ${otp}`;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alert Box</title>
</head>
<body>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Alert Box</title>
</head>
<body>
//eventListener
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>event listener</title>
<style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>event listener</title>
<style>
// Functions in JavaScript...
function myFunction(){
console.log("Hi JavaScript!");
console.log("I'm Shubham");
}
myFunction();
// using parameters
function myFunction(){
console.log("Hi JavaScript!");
console.log("I'm Shubham");
}
myFunction();
// using parameters
// DOM Manipulation
// textContent properties
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
// textContent properties
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
// Conditional Statement...
// if statement
let num = prompt("Enter your age:");
if(num >= 18){
console.log("Eligible for vote");
}
// if statement
let num = prompt("Enter your age:");
if(num >= 18){
console.log("Eligible for vote");
}