Home » JavaScript (page 30)

JavaScript

A JavaScript Unit Test Trap

You’re a few months into writing a shiny new web app, and the team just settled on some new standards for data structures used for communication with the server. You’ll need to refactor a few pages, but that’s not a big deal. Your team has been pushing good unit testing practices, and you’ve got great coverage for the affected code. ...

Read More »

jQuery Document Ready Example

In this example, we’ll have a look into jQuery $( document ).ready(). This is the starting point of almost all of our jQuery code, so there stands a reason why developers should have a clear understanding why it is used and how important it is. Whenever you use jQuery to manipulate your web page, you wait until the document ready ...

Read More »

Javascript location.href Example

In these example we’re going to discuss and learn about the location.href property. Let’s dive right in!                     Definition and syntax The location.href property is a read-only one, that returns the URL of the current page, or sets one in case it’s modified.It’s syntax goes like below: It will return the ...

Read More »

Angular.js Grid Example

We all know that Angular is the most famous JavaScript framework, at this time and one of the main reasons that lead it to the top is that it provides many modules, ready to ease your development effort. So, what about tables? Is there any angular module, in order to avoid using the old-stylish HTML markup? 1. Introduction Obviously, there ...

Read More »

jQuery Add/Remove Class Example

In this example, we’ll go through jQuery .addClass() and .removeClass() methods. jQuery provides a seamless, easy and efficent way to add or remove classes to specific DOM elements and trigger these events on the various listening events it provides like click, mouseover, mouseleave ect. These methods are very useful to dynamically change content based on your cases, and gives your ...

Read More »

jQuery UI Datepicker Example

In this example, we’ll have a look at the datepicker widget of jQuery. The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily. By default, the datepicker calendar opens in a small ...

Read More »

Javascript Close Window Example

This time we’re going to explain how to close a window, regardless of whether it has been opened by a script or not. Take a look!                     Closing the script-open window To close windows we have opened by a script we use the built-in Javascript method window.close(), which is also it’s ...

Read More »

jQuery AJAX Example

The aim of this example is to give you a full understanding of AJAX, which stands for Asynchronous Javascript and XML. Ajax is not a programming language or a tool, but a concept. Ajax is a client-side script that communicates to and from a server/database without the need for a postback or a complete page refresh. The best definition for ...

Read More »

Javascript ParseInt / String-to-int Example

Let’s suppose you receive from the user of your site some data, in string form, which should be converted to integer before you use them again. For that, you can use the parseInt() function. But how can you do that exactly, and also reverse this action? Let’s see below.                 Syntax The parseInt() ...

Read More »