The aim of this example is to show you how to use the jQuery .trim() method. Sometimes we need to remove the whitespace (newlines, spaces and tabs) from the beginning and the end of a string. For this purpose we can use jQuery .trim() method. If these whitespace characters occur in the middle of the string, they are preserved. Let’s ...
Read More »Home » Archives for Saeb Najim »
jQuery getJSON example
The goal of this example is to show you how to use the jQuery .getJSON() method. The JavaScript Object Notation (JSON) is a data interchanging format. JSON is a set of key/value pairs, the value may be a string, boolean, number, object or an array. As an example look at this personal information in json format: {"name":"maykel","age":25}. To get the ...
Read More »jQuery clone example
The aim of this example is to show you how to use the jQuery .clone() method . Sometimes we need to copy the HTML element and work with the copied element. The jQuery .clone() method is used for this purpose. This method performs a deep copy of the set of matched elements, meaning that it copies the matched elements as ...
Read More »jQuery bind example
The aim of this example is to show you how to use the jQuery bind() method. This method is used to attach a handler to an event of HTML elements. This method has three overloaded signatures 1- .bind( eventType [, eventData ], handler ) The event type is the event name as “click”,”change”, etc. This method can bind one handler ...
Read More »jQuery change example
The purpose of this example is to show you how to use the jQuery .change() method. The users of a dynamic web page make many operations to change HTML elements as the text entering into an input text field, the comboboxes selection, the checkboxes un/checking and so on. To detect these changes and get the changed HTML element’s value, we ...
Read More »jQuery contains example
The aim of this example is to show you how to pick the DOM elements that contain a specific string. jQuery provides the :contains selector for this purpose. The jQuery :contains('text') selector helps you to find the HTML elements containing the given text. The text can be contained directly in the element or in a child element. For example, this ...
Read More »jQuery Popup Window example
The aim of this example is to show you how to use popup windows with jQuery. jQuery provides a good plugin that can be used for this purpose. A Popup window has a title and some content that may be a simple message or any HTML code (e.g. a login form etc.) The jQuery dialog() method is used to show ...
Read More »jQuery forEach example
This example explains how to use iteration in jQuery. jQuery provides a powerful function for looping over elements. The jQuery each() function helps to iterate over an array, object properties and all HTML elements. This function has many overloaded signatures that take different arguments, all overloaded signatures take anonymous callback function to deal with current item. Let’s look at some ...
Read More »jQuery get id example
The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily. The element id must be unique in the HTML document. Getting it helps us in many situations like determining the pressed element or focused element in a page etc. The jQuery ...
Read More »