Ricky Barnes has Published 119 Articles

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

What are Event Methods in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 14-Feb-2020 10:44:08

205 Views

Commonly used event methods include $(document).ready(), click(), dblclick() etc. There is a list of methods which can be called on an Event Object, The following are some of the methods which can be called on an Event Object, S.NoMethod and Description1preventDefault() Prevents the browser from executing the default action.2isDefaultPrevented() Returns whether event.preventDefault() ... 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

How to remove event handlers using jQuery?

Ricky Barnes

Ricky Barnes

Updated on 14-Feb-2020 10:37:08

1K+ Views

Once an event handler is established, it remains in effect for the remainder of the life of the page. There may be a need when you would like to remove event handler.jQuery provides the unbind() command to remove an exiting event handler. The syntax of unbind() is as follows.The following ... Read More

How to get innerHTML of a div tag using jQuery?

Ricky Barnes

Ricky Barnes

Updated on 14-Feb-2020 05:11:51

4K+ Views

To get the innerHTML of a div tag in jQuery, use the class with innerHTML. You can try to run the following code to learn how to get innerHTML of a div tag using jQuery −ExampleLive Demo  $(document).ready(function(){    $("#button1").click(function(){      var one = $('.a').innerHTML; ... Read More

How to replace innerHTML of a div tag using jQuery?

Ricky Barnes

Ricky Barnes

Updated on 14-Feb-2020 05:10:41

3K+ Views

To replace innerHTML of a div tag, use the html() method. The dot notation calls the html() method to replace the inner html with  the parameter placed between, i.e. Demo here. The html() here modifies the .innerhtml.ExampleYou can try to run the following code to to replace innerHTML of a ... Read More

What does html() method do in jQuery?

Ricky Barnes

Ricky Barnes

Updated on 14-Feb-2020 05:09:35

163 Views

The html() method sets or returns the content of elements selected. jQuery has a some methods to manipulate attributes, including the html() method. These are DOM related methods. The attributes include, text() – This method sets or returns the text content of elements selected.html() – This method sets or returns ... Read More

How to toggle between two classes in jQuery?

Ricky Barnes

Ricky Barnes

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

812 Views

To toggle between two classes in jQuery, use the addClass() and removeClass() method. You can try to run the following code to toggle between two classes in jQuery −ExampleLive Demo                          $(document).ready(function(){           ... Read More

How to add a title in anchor tag using jQuery?

Ricky Barnes

Ricky Barnes

Updated on 13-Feb-2020 09:54:55

3K+ Views

To add a title in anchor tag in jQuery, use the prop() method. The prop() method is used to set properties and values of the selected elements.You can try to run the following code to learn how to add a title in anchor tag using jQuery −ExampleLive Demo         ... Read More

How to add and remove a class to an anchor tag with jQuery?

Ricky Barnes

Ricky Barnes

Updated on 13-Feb-2020 09:48:48

2K+ Views

To add and remove a class to an anchor tag, use the toggleClass. Using it you can add and remove a class on a click.You can try to run the following code to learn how to add and remove a class to an anchor tag with jQuery −ExampleLive Demo   ... Read More

Advertisements