Arnab Chakraborty

Arnab Chakraborty

29 Articles Published

Articles by Arnab Chakraborty

Page 2 of 3

How can I remove all child elements of a DOM node in JavaScript?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 14K+ Views

When building web applications, you often need to clear dynamic content like task lists, shopping carts, or search results. JavaScript provides several methods to remove all child elements from a DOM node efficiently. Here are the main approaches to remove all child elements: Using the removeChild() method with iteration Setting innerHTML to an empty string Using jQuery's empty() method Using the modern replaceChildren() method Using removeChild() Method with Iteration This method iterates through all child nodes and removes them one by one using removeChild(). It's reliable and works across all browsers. Syntax ...

Read More

Count spaces, uppercase and lowercase in a sentence using C

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 969 Views

In C programming, counting different types of characters in a string is a common task. This involves analyzing each character to determine if it's uppercase, lowercase, a digit, whitespace, or a special character. Syntax for (int i = 0; str[i] != '\0'; i++) { // Check character type using ASCII values if (str[i] >= 'A' && str[i] = 'a' && str[i] = '0' && str[i] = 'A' && str[i] = 'a' && str[i] = '0' && str[i]

Read More

How can I write in order with for loop or while loop?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 322 Views

In C programming, we can create ordered patterns using for loops or while loops. This example demonstrates how to generate a specific numerical pattern where each line contains repeating digits based on the line number. Syntax for(initialization; condition; increment) { // loop body } while(condition) { // loop body increment; } Method 1: Using For Loop This approach uses nested for loops to create a pattern where each line displays the line number followed by repeating 0s and 1s − ...

Read More

How to get the content of a textarea using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Mar-2026 774 Views

In jQuery, you can easily retrieve the content of a textarea element using the val() method. This method returns the current value of form elements, including textareas. Basic Syntax The basic syntax to get textarea content is − var content = $("#textareaId").val(); Example Here is a complete example using one textarea and one button. The textarea is used for user input, then clicking the button displays the value in an alert box − ...

Read More

How to get current URL in jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Mar-2026 4K+ Views

For getting the current URL in jQuery, you can use the attr() method with the location object or the native JavaScript window.location property. Both methods provide access to the complete URL of the current page. Methods to Get Current URL There are two main approaches − 1. Using jQuery's attr() method: $(location).attr('href') returns the complete URL as a string. 2. Using window.location: The native JavaScript window.location object provides access to the current URL and its components. Example Here's a complete example demonstrating both methods − ...

Read More

How to check if a div is visible using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Mar-2026 13K+ Views

You can use .is(':visible') to check if a div element is visible. This jQuery selector returns true if the element is currently visible on the page, and false if it's hidden through CSS properties like display: none, visibility: hidden, or if its width and height are set to zero. Example The following example demonstrates how to check if a div is visible and show it if it's hidden − Check Div Visibility with jQuery ...

Read More

How to count number of rows in a table with jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Mar-2026 2K+ Views

Counting the number of rows in a table is a common requirement in web development. jQuery provides several methods to count table rows efficiently. In this tutorial, we'll learn how to count table rows using jQuery's .length property. Basic Method to Count Table Rows The simplest way to count table rows is by using jQuery's selector to target all tr elements within a table and then use the .length property to get the count. Example Here's a complete example that demonstrates how to count table rows − Count ...

Read More

How to disable/enable an input box with jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Mar-2026 18K+ Views

We can easily disable input boxes (textbox, textarea) using the disabled attribute. When an input element is disabled, users cannot interact with it, and it won't be included in form submissions. Using attr() and removeAttr() Methods To disable an input element − $('elementname').attr('disabled', 'disabled'); To enable a disabled element, we need to remove the "disabled" attribute from the element − $('elementname').removeAttr('disabled'); Using prop() Method (Recommended) jQuery also provides the prop() method which is recommended for boolean attributes like disabled − // To disable $('elementname').prop('disabled', true); // ...

Read More

How can I get the ID of an DOM element using jQuery?

Arnab Chakraborty
Arnab Chakraborty
Updated on 13-Mar-2026 806 Views

In jQuery, the attr() method is used to get the id attribute of the first matching element. This method allows you to retrieve any attribute value from a DOM element. Syntax The basic syntax to get an element's ID using jQuery is − $(selector).attr("id") Where selector is the jQuery selector that identifies the element whose ID you want to retrieve. Example Here's a complete example that demonstrates how to get the ID of a DOM element when a button is clicked − Getting DOM ...

Read More

How to match a line not containing a word in Java Regex

Arnab Chakraborty
Arnab Chakraborty
Updated on 11-Mar-2026 540 Views

Exampleimport java.util.regex.Matcher; import java.util.regex.Pattern; public class NoRegTest {    public static void main(String[] args) {       String s="^fun";       Pattern pattern = Pattern.compile(s);       Matcher matcher = pattern.matcher("Java is fun");       if(!matcher.find()) {          System.out.println("not found");       }    } }Outputnot found

Read More
Showing 11–20 of 29 articles
Advertisements