Articles of level

Intermediate

The getJSON() method of jQuery is specifically used to load JSON data by using HTTP GET request. JSON, an acronym for the JavaScript Object Notation, is a lightweight data-interchange format, used to store and exchange text information.

Sometimes you need to change the attributes of elements in your web page upon user actions or some other reason. For example, changing the image dimensions, height and width in the web page. Similarly, changing the paragraph, div properties, table borders, background color attributes etc. without reloading the web page. Similarly, it may also be required to get elements attributes, like current image height or width, table width etc. on the basis of which you can perform some action, all without reloading the web page. This is where jQuery attr works. The attr method is used to set or get/return element attributes in the document.
Syntax of jQuery attr
$(“element”).attr(“property”,”value”);
The syntax to Get attribute value is:
$(“element”).attr(“property”);
Where an element can be an image, a div, paragraph, table etc.
Note that, if you use attr jQuery method to set the attribute(s) of element, it will change attributes to all matched elements. Whereas in case of using it to return attribute value, it will return only the first matched element value.

jQuery serialize() method is used to create a text string in standard URL-encoded notation. It is used in form controls like <input>, <textarea>, <select> etc. It serializes the form values so that its serialized values can be used in the URL query string while making an AJAX request.
Syntax:
$ (selector).serialize()   

The delegate () method is used to attach one or more event handlers for specified elements which are the children of selected elements. This method executes a function to run when the event occurs.
The attached event handlers with the delegate () method works for both current and future elements.
Syntax:
$(selector).delegate(childSelector,event,data,function)

Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*