The global property in JavaScript returns true or false depending upon if the ‘g’ modifier is set or not.Following is the code for JavaScript global property −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample, .result { font-size: 18px; font-weight: 500; } JavaScript global Property Some random text inside a div CLICK HERE Click on the above button to check if the 'g' modifier is set or not let ... Read More
The getTime() method in JavaScript returns the number of milliseconds elapsed since 1st January 1970.Following is the code for getTime() function −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; } JavaScript getTime() Method CLICK HERE Click on the above button to get the seconds elapsed since January 1st 1970 let sampleEle = document.querySelector(".sample"); let date = new Date(); document.querySelector(".Btn").addEventListener("click", () => { sampleEle.innerHTML = "Seconds elapsed since 01/01/1970 = " + date.getTime(); }); OutputOn clicking the “CLICK HERE” button −
To get the text of the span element in JavaScript, the code is as follows −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .sample { font-size: 18px; font-weight: 500; } JavaScript Date Methods This is some sample text inside a span element CLICK HERE Click on the above button to get the span text let sampleEle = document.querySelector(".sample"); let spanEle = document.querySelector(".test"); document.querySelector(".Btn").addEventListener("click", () => { sampleEle.innerHTML = "The span text is = " + spanEle.innerHTML; }); OutputOn clicking the “CLICK HERE” button −
To implement JavaScript Auto Complete / Suggestion feature, the code is as follows −Example Live Demo body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } JavaScript Auto Complete / Suggestion feature var tags = ["orange", "apple","pineapple","guava","mango","pomegranate","litchi",]; let check; document.querySelector(".fruits").addEventListener("keyup", (event) => { let value = event.target.value; document.getElementById("datalist").innerHTML = ""; tags.forEach((item) => { if (item.toLowerCase().indexOf(value.toLowerCase()) > -1) { var opt = document.createElement("option"); var sel = document.createTextNode(item); opt.appendChild(sel); document.getElementById("datalist").appendChild(opt); } }); }); OutputOn typing something in the input field −
The property opacity is the ultimate and modern solution and works for Firefox 0.9+, Safari 2, opera 9+, IE 9+ and every version of Google Chrome. The -moz-opacity property is the opacity property for Firefox versions older than 0.9 while the –khtml-opacity property is for safari versions starting with 1. The filter property is for IE browsers from 5 to 9 to give opacity like effect.Following is code for image opacity using CSS for all browsers −Example Live Demo body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } img { width:270px; height:200px; } .transparent{ ... Read More
The Advanced Selectors in CSS includes Adjacent Sibling selector, attribute selector, direct child selector, nth-of-type selector, etc. It also includes General Sibling Selector, an example is shown below:h1 ~ h3Example of direct child selector −div > spanFollowing is the code showing advanced selectors in CSS −Example Live Demo #red { color: red; } .green { background: green; } ul:nth-of-type(1) { background: rgb(0, 174, 255); } ul + h3 { border: 4px solid rgb(19, 0, 128); } a[href="https://www.wikipedia.org"] { font-size: 25px; } h1 ~ h3 { font-size: 40px; } div > span { ... Read More
To create CSS3 Transition Effects, use the transition property. Following is the code for creating transition effects using CSS3 −Example Live Demo .container div { width: 300px; height: 100px; background: rgb(25, 0, 255); border: 2px solid red; transition: width 2s; } .container:hover div { width: 100px; } Transition effects example Hover over the above div to reduce its width OutputThe above code will produce the following output −On hovering above the div −
To get the mean daily average count of recorded documents, use aggregate(). Within that, use $project and $group.Let us create a collection with documents −Example> db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-15T10:50:35.000Z"), ... Value: 10 ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6e9") } > db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-14T10:50:35.000Z"), ... Value: 10 ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6ea") } > db.demo451.insertOne({ ... DueDate:new ISODate("2020-03-13T10:50:35.000Z"), ... Value: 10 ... } ... ); { "acknowledged" : true, "insertedId" : ObjectId("5e7b5c5d71f552a0ebb0a6eb") }Display all documents from a collection with the help of find() ... Read More
To implement string comparison in MongoDB, use $strcasecmp. It performs case-insensitive comparison of two strings. It returns −1 if first string is “greater than” the second string.0 if the two strings are equal.-1 if the first string is “less than” the second string.Let us create a collection with documents −> db.demo490.insertOne({"Name1":"John", "Name2":"john"});{ "acknowledged" : true, "insertedId" : ObjectId("5e8496ccb0f3fa88e22790bb") } > db.demo490.insertOne({"Name1":"David", "Name2":"Bob"});{ "acknowledged" : true, "insertedId" : ObjectId("5e8496d9b0f3fa88e22790bc") } > db.demo490.insertOne({"Name1":"Carol", "Name2":"Carol"});{ "acknowledged" : true, "insertedId" : ObjectId("5e8496e5b0f3fa88e22790bd") }Display all documents from a collection with the help of find() method −> db.demo490.find();This will produce ... Read More
Use update() in MongoDB to update array object. The usage of dot notation is also required. Let us create a collection with documents −> db.demo489.insertOne( ... { ... ... ... details : [{ ... id : 101, ... "Info1" : { ... "StudentName" : "Chris" ... }, ... "Info2" : { ... "TeacherName" : "David" ... } ... }, ... { ... id : 102, ... "Info1" : ... Read More
 
 Data Structure
 Data Structure Networking
 Networking RDBMS
 RDBMS Operating System
 Operating System Java
 Java MS Excel
 MS Excel iOS
 iOS HTML
 HTML CSS
 CSS Android
 Android Python
 Python C Programming
 C Programming C++
 C++ C#
 C# MongoDB
 MongoDB MySQL
 MySQL Javascript
 Javascript PHP
 PHP