Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 395 of 534
Split Button Dropdowns with Bootstrap
Split button dropdowns use the same general style as the dropdown button but add a primary action along with the dropdown. Split buttons have the primary action on the left and a toggle on the right that displays the dropdown. Basic Structure A split button dropdown consists of two buttons wrapped in a btn-group container: Primary button: Performs the main action when clicked Dropdown toggle: Shows/hides the dropdown menu with additional options Example You can try to run the following code to create split button dropdowns: ...
Read MoreAlign the components with Bootstrap
Bootstrap provides utility classes to align navbar components horizontally. Use .navbar-left to float elements to the left and .navbar-right to float elements to the right within the navbar. Alignment Classes Bootstrap offers two primary classes for navbar alignment: .navbar-left - Floats elements to the left side of the navbar .navbar-right - Floats elements to the right side of the navbar These classes can be applied to navigation lists, forms, buttons, and text elements within the navbar. Example Here's a complete example demonstrating left and right alignment of various navbar components: ...
Read MoreGet Bootstrap Jumbotron of full width and without rounded corners
To get a jumbotron of full width and without rounded corners, use the .jumbotron class outside all .container classes and instead add a .container within. This approach makes the jumbotron span the entire viewport width while keeping the content properly centered. Default vs Full-Width Jumbotron When you place .jumbotron inside a container, it has rounded corners and limited width. Placing it outside removes these constraints: Placement Width Rounded Corners Use Case Inside .container Limited Yes Card-like appearance Outside .container Full viewport No Hero sections, landing pages Example ...
Read MoreBootstrap Collapsible list group
To create a collapsible list group in Bootstrap, combine the panel-collapse property with the list-group property. This creates an expandable section containing a list of items that can be toggled with a click. Basic Structure A collapsible list group consists of three main components: Panel container: Wraps the entire collapsible section Panel header: Contains the clickable trigger element Collapsible content: Houses the list group items Example The following example demonstrates a collapsible list group with programming languages. Click the "Info" header to expand or collapse the list: ...
Read MoreArrays Data Structure in Javascript
The array is a container which can hold a fixed number of items and these items should be of the same type. It stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. Why do we need arrays? Let's say you want to record the average temperatures of all days of the week. You can record them as follows − let avgTempMon = 35; let ...
Read MoreAdding an element at the end of the array in Javascript
In JavaScript, adding elements to the end of an array is a fundamental operation. The most common and efficient method is using the push() method, which modifies the original array by appending one or more elements. An array is a special variable that can hold multiple values in a single ordered collection. Arrays in JavaScript are dynamic, meaning you can add or remove elements after creation. What is an Array? An array is a collection of items stored at contiguous memory locations. Arrays allow random access to elements, making it faster to access elements by their position ...
Read MoreAdding an element at the start of the array in Javascript
In JavaScript, adding an element at the start of an array is a common operation. The most straightforward method is using the unshift() method, which adds one or more elements to the beginning of an array and returns the new length. An array is a data structure that stores multiple values in a single variable. Arrays in JavaScript are zero-indexed, meaning the first element is at position 0. Syntax array.unshift(element1, element2, ..., elementN) Parameters The unshift() method accepts one or more parameters representing the elements to add at the beginning of the array. ...
Read MoreRemoving an element from the start of the array in javascript
In JavaScript, there are several methods to remove the first element from an array. The most common approaches are using the shift() method, slice() method, or the Underscore.js _.rest() method. Using shift() Method (Recommended) The shift() method removes and returns the first element from an array, modifying the original array. Syntax array.shift() Example Remove first element using shift() ...
Read MoreRemoving an element from a given position of the array in Javascript
In JavaScript, you can remove an element from a specific position in an array using several methods. Each approach has different behaviors and use cases. Syntax Here are the main syntaxes for removing elements: // Delete operator (leaves undefined) delete arr[index]; // Slice method (creates new array) arr.slice(0, index).concat(arr.slice(index + 1)); // Splice method (modifies original array) arr.splice(index, 1); Using delete Operator The delete operator removes an element but leaves undefined in its place, keeping the array length unchanged. Remove element using delete ...
Read MoreSearching an element in Javascript Array
JavaScript provides several methods to search for elements in arrays. Each method has its own use case depending on whether you're searching for primitive values or complex objects. Using indexOf() for Primitive Values The indexOf() method searches through the array and returns the index of the first matching element, or -1 if not found. let people = ["Harry", "Martha", "John", "Sam"]; console.log(people.indexOf("John")); console.log(people.indexOf("Jim")); 2 -1 Using find() for Complex Objects The find() method returns the first element that matches the condition provided in the callback function. let people ...
Read More