Ricky Barnes has Published 101 Articles

How to get selected text from a drop-down list (select box) using jQuery?

Ricky Barnes

Ricky Barnes

Updated on 12-Jun-2020 12:50:48

1K+ Views

With jQuery, it’s easy to get selected text from a drop-down list with :selected. This is done using the select id. You can try to run the following code to learn how to get selected text from a drop-down list using jQuery −ExampleLive Demo           jQuery ... Read More

How do I check if an element is hidden in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 12-Jun-2020 12:48:51

265 Views

Using jQuery, you can detect if a specific element in the page is hidden or visible with is(:visible). You can try to run the following code to learn how to check if an element is hidden in jQuery or not −ExampleLive Demo           jQuery Selector   ... Read More

How to write a custom jQuery plugin?

Ricky Barnes

Ricky Barnes

Updated on 12-Jun-2020 09:00:13

329 Views

To create a jQuery plugin, first create a file named jquery-demoplugin.js with the following code. This is our plugin code. Here, demoplugin is the name of our plugin. You can add any name to your custom plugin −(function ( $ ) {    $.fn.demoplugin = function( options ) {     ... Read More

What is the difference between jQuery.load() and jQuery.ajax() methods in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 17-Feb-2020 07:23:14

621 Views

jQuery ajax() methodThe jQuery.ajax( options ) method loads a remote page using an HTTP request. $.ajax() returns the XMLHttpRequest that it creates. In most cases you won't need that object to manipulate directly, but it is available if you need to abort the request manually.Here is the description of all ... Read More

What is the difference between jQuery.load() and jQuery.get() methods in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 17-Feb-2020 07:17:43

709 Views

jQuery load() methodThe load( url, data, callback ) method loads data from the server and places the returned HTML into the matched element.Here is the description of all the parameters used by this method −url − A string containing the URL to which the request is sent.data − This optional parameter represents ... Read More

What is the difference between jQuery.post() and jQuery.get() methods in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 17-Feb-2020 07:13:59

336 Views

jQuery post() methodThe jQuery.post( url, [data], [callback], [type] ) method loads a page from the server using a POST HTTP request.Assuming we have following PHP content in result.php file, ExampleThe following is the code snippet showing the usage of this method −                ... Read More

How to put a complete HTML page in a div using jQuery?

Ricky Barnes

Ricky Barnes

Updated on 17-Feb-2020 07:06:12

671 Views

To put complete HTML page in a div using jQuery, use the load() method. Firstly, add the web page you want to add.Here’s the code for new.html −     Heading 1 Demo text ExampleNow, the code for the HTML file which adds the above page, ... Read More

How do I access values created by serializeArray in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 17-Feb-2020 07:00:20

711 Views

To access values creates by serializeArray, use the serializeArray( ) method. The serializeArray( ) method serializes all forms and form elements like the .serialize() method but returns a JSON data structure for you to work with.Let’s say we have the following PHP content in serialize.php file −The following is an example ... Read More

How to get value from serialized array in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 17-Feb-2020 06:56:19

4K+ Views

To get value from serialized array, use th serializeArray( ) method. The serializeArray( ) method serializes all forms and form elements like the .serialize() method but returns a JSON data structure for you to work with.Let’s say we have the following PHP content in serialize.php file −The following is an ... Read More

How to get attribute of an element when using the 'click' event in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 14-Feb-2020 10:40:25

3K+ Views

To get attribute of an element, use the attr() method in jQuery. You can try to run the following code to get attribute of an element using the ‘click’ event −ExampleLive Demo $(document).ready(function(){     $("button").click(function(){         alert("Width of image: " + $("img").attr("width"));     }); }); Get Width

Advertisements