AmitDiwan

AmitDiwan

8,390 Articles Published

Articles by AmitDiwan

Page 564 of 839

JavaScript Error message Property

AmitDiwan
AmitDiwan
Updated on 07-May-2020 259 Views

The error message property sets or returns an error message in JavaScript. Following is the code for the error message property −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 18px;       font-weight: 500;    } JavaScript Error message Property CLICK HERE Click on the above buttons to see the error message    let sampleEle = document.querySelector(".sample");    document.querySelector(".Btn").addEventListener("click", () => {       try {          confrm('Are you sure');       } catch (e) {          sampleEle.innerHTML = "Error: " + e.message;       }    }); OutputOn clicking the “CLICK HERE” button −

Read More

JavaScript encodeURI(), decodeURI() and its components functions

AmitDiwan
AmitDiwan
Updated on 07-May-2020 353 Views

The encodeURI() function encodes the complete URI including special characters except except (, / ? : @ & = + $ #) characters.The encodeURIComponent() function encodes some parts of the URI by basically encoding the special characters. It also encodes the following characters − (, / ? : @ & = + $ # )The decodeURI() function decodes the URI generated by the encodeURI() function.The decodeURIComponent() function is used to decode some parts of URI generated by encodeURIComponent().Following is the code for the encodeURI(), decodeURI() and its component functions −Example Live Demo Document    body { ...

Read More

JavaScript – Getting Coordinates of mouse

AmitDiwan
AmitDiwan
Updated on 07-May-2020 516 Views

To get the coordinates of mouse using JavaScript, the code is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample {       font-size: 25px;       font-weight: 500;    } Coordinates of mouse Hover the mouse over the screen to get its x and y axis position    let sampleEle = document.querySelector(".sample");    document.body.addEventListener("mousemove", (event) => {       sampleEle.innerHTML = "X axis: " + event.x + " Y axis: " + event.y;    }); OutputThe above code will produce the following output:

Read More

JavaScript Const

AmitDiwan
AmitDiwan
Updated on 07-May-2020 329 Views

The JavaScript const declarations create variables that cannot be reassigned to some other value or redeclared later. It was introduced in ES2015.Following is the code for JavaScript const declaration −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    } Const example CLICK HERE Click the above button to try changing const value    let sampleEle = document.querySelector(".sample");    const a = 33;    sampleEle.innerHTML = "a = " + a + "";    document.querySelector(".Btn").addEventListener("click", () => {       try {          a = 44;       } catch (err) {          sampleEle.innerHTML += "Error : " + err;       }    }); OutputOn clicking the ‘CLICK HERE’ button to change constant value −

Read More

JavaScript Auto-filling one field same as other

AmitDiwan
AmitDiwan
Updated on 07-May-2020 414 Views

To auto-filling one field same as other, the JavaScript script is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    } JavaScript Auto-filling one field same as other Enter your primary address Address Pin Code Secondary Address same as primary Same Address Enter your secondary address Address Pin Code    let checkEle = document.querySelector(".check");    let addressEle = document.querySelectorAll(".address");    let pinCodeEle = document.querySelectorAll(".pincode");    checkEle.addEventListener("change", (event) => {       if (event.target.checked) {          console.log(addressEle[0].value);          addressEle[1].value = addressEle[0].value;          pinCodeEle[1].value = pinCodeEle[0].value;       }    }); OutputOn filling the primary address and clicking the “Same Address” checkbox −

Read More

JavaScript symbol.@@toPrimitive() function

AmitDiwan
AmitDiwan
Updated on 07-May-2020 155 Views

The symbol.@@toPrimitive() function converts a symbol object to a primitive value.SyntaxSymbol()[Symbol.toPrimitive](hint)The hint value specifies the type eg − number, string, etc and is an optional argument.Following is the code for symbol.@@toPrimitive() function −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    div {       font-size: 20px;       font-weight: 500;    } JavaScript symbol.@@toPrimitive() function CLICK HERE Click on the above button to add the object with a number.    let fillEle = document.querySelector(".sample");   ...

Read More

How to create a flip card with CSS?

AmitDiwan
AmitDiwan
Updated on 07-May-2020 310 Views

To create a flip card with CSS, the code is as follows −Example Live Demo    body {       font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;       margin:20px;    }    .flipCard {       background-color: transparent;       width: 300px;       height: 300px;       perspective: 1000px;    }    .innerCard {       position: relative;       width: 100%;       height: 100%;       text-align: center;       transition: transform 0.6s;       transform-style: preserve-3d;       box-shadow: ...

Read More

How to create a simple "star rating" look with CSS?

AmitDiwan
AmitDiwan
Updated on 07-May-2020 387 Views

To create a simple star rating look with CSS, the code is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;       margin: 30px;    }    .fa {       font-size: 30px;       color: grey;    }    .rated {       color: rgb(255, 0, 0);       border: 2px solid yellow;    } Star Rating Example OutputThe above code will produce the following output −

Read More

Creating CSS3 Radial Gradients

AmitDiwan
AmitDiwan
Updated on 07-May-2020 170 Views

For Radial Gradients, set color stops. The default shape is Ellipse, but you can also set other shapes like circle. Set at least two color stops for Radial Gradients in CSS.Following is the code for creating radial gradients using CSS −Example Live Demo body {    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } #radial {    height: 200px;    width: 200px;    background-image: radial-gradient(       rgb(255, 0, 106),       rgb(2, 0, 128),       rgb(0, 255, 42)    ); } Radial Gradient Example OutputThe above code will produce the following output −

Read More

How to create a collapsible section with CSS and JavaScript?

AmitDiwan
AmitDiwan
Updated on 07-May-2020 1K+ Views

To create a collapsible section with CSS and JavaScript, the code is as follows −Example Live Demo    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .collapse {       background-color: rgb(83, 186, 255);       color: white;       cursor: pointer;       padding: 18px;       width: 100%;       border: none;       text-align: left;       outline: none;       font-size: 18px;    }    .active, .collapse:hover {       background-color: rgb(34, 85, 160);    } ...

Read More
Showing 5631–5640 of 8,390 articles
« Prev 1 562 563 564 565 566 839 Next »
Advertisements