Found 10711 Articles for Web Development

How to disable/enable an input box with jQuery?

Arnab Chakraborty
Updated on 22-Jun-2020 07:59:30

16K+ Views

We can easily disable input box(textbox,textarea) using disable attribute to “disabled”.$(‘elementname’).attr(‘disabled’,’disabled’);To enable disabled element we need to remove “disabled” attribute from this element.$(‘elementname’).removeAttr(‘disabled’);Example    ed                      $(document).ready(function () {             $('#btn1').click(function () {                $('input').attr('disabled', 'disabled');             });             $('#btn2').click(function () {                $('input').removeAttr('disabled');             });          });              Disable    Enable

How to globally disable an animation using jQuery?

Ricky Barnes
Updated on 21-Jun-2020 12:44:58

697 Views

To globally disable an animation using jQuery, use the jQuery.fx.off() method.To enable animation:$("#enable").click(function(){    jQuery.fx.off = false; });To disable animation, set jQuery.fx.off() as true:$("#disable").click(function(){    jQuery.fx.off = true; });You can try to run the following code to globally disable an animation using jQuery:Example Live Demo The jQuery Example               $(document).ready(function() {          $("#enable").click(function(){             jQuery.fx.off = false;          });          $("#disable").click(function(){             jQuery.fx.off = true;          });   ... Read More

How to add easing effect to your animation with jQuery?

Ricky Barnes
Updated on 21-Jun-2020 13:14:24

500 Views

To add easing effect to your animation, use the animation speed properly to form it a perfect animation for the web page. Do not speed up animation and you should know where to stop it while using animate().Here for our example, we have a button that takes you to a textarea to add an answer:    Add answer Now set the fade out property properly to set easing effect.Example Live Demo               $(document).ready(function(){          $('body').on('click', '#answer', function() {             var container = $('.new-answer');   ... Read More

How to use $.fadeTo() method to create animation in jQuery?

Alex Onsman
Updated on 22-Jun-2020 08:07:11

111 Views

The fadeTo( ) method fades the opacity of all matched elements to a specified opacity and firing an optional callback after completion.Here is the description of all the parameters used by this method −speed - A string representing one of the three predefined speeds ("slow", "def", or "fast") or the number of milliseconds to run the animation (e.g. 1000).opacity − A number between 0 and 1 denoting the target opacity.callback − This is optional parameter representing a function to call once the animation is complete.You can try to run the following code to learn how to work with fadeTo() method ... Read More

What is the difference between jQuery.animate() and jQuery.hide()?

David Meador
Updated on 22-Jun-2020 08:05:11

214 Views

jQuery animate()The animate( ) method performs a custom animation of a set of CSS properties.Here is the description of all the parameters used by this method −params − A map of CSS properties that the animation will move toward.duration − This is optional parameter representing how long the animation will run.easing − This is optional parameter representing which easing function to use for the transition.callback − This is optional parameter representing a function to call once the animation is complete.You can try to run the following code to learn how to work with jQuery animate() method:Example Live Demo   ... Read More

How can I make jQuery animations smoother?

Kristi Castro
Updated on 22-Jun-2020 08:44:07

512 Views

To make jQuery animations smoother use the easing library. Use the animation speed properly to form it a perfect animation for the web page. Do not speed up animation and you should know where to stop it while using animate().For an example, set a button, that fades out on click and displays a textarea:Add answerThe following is the textarea that generates showing smoother animation using animation() and fadeout(): You can try to run the following code to make jQuery animation smoother:Example Live Demo               $(document).ready(function(){          $('body').on('click', '#answer', function() ... Read More

How to animate a change in background color using jQuery on mouseover?

Kristi Castro
Updated on 22-Jun-2020 08:41:49

616 Views

To change background color, use the mouseenter event. The background color change when you place mouse cursor:mouseenter: function(){    $(this).css("background-color", "gray"); }The mouse cursor is placed on the following element:Click and move the mouse pointer to change the background color.You can try to run the following code to learn how to animate a change in background color on mouseover:Example Live Demo               $(document).ready(function(){          $("body").on({             mouseenter: function(){                $(this).css("background-color", "gray");             },                 mouseleave: function(){                $(this).css("background-color", "red");             },              });       });        Click and move the mouse pointer to change the background color.

How animate(), hide and show elements using jQuery?

David Meador
Updated on 12-Dec-2019 08:34:30

3K+ Views

Use the hide() and show() method with animate() to hide and show elements.ExampleYou can try to run the following code to learn how to work with animate() method to hide and show elements:Live Demo $(document).ready(function(){     $("#btn1").click(function(){         $("#box").animate({height: "300px"}, 500, function() {            $(this).hide();         });     });    $("#btn2").click(function(){         $("#box").animate({height: "300px"}, 500, function() {            $(this).show();         });     }); }); Hide Show

How to use jQuery.toggle() method in jQuery?

David Meador
Updated on 12-Dec-2019 08:57:49

138 Views

The toggle() method toggles displaying each of the set of matched elements.ExampleYou can try to run the following code to learn how to work with jQuery.toggle() method:Live Demo           jQuery toggle() method                                  $(document).ready(function() {             $("#toggle").click(function(){                $(".target").toggle( );             });          });                                          p {              background-color:#bca;              width:200px;              border:1px solid green;          }                         Click on the following button:       Toggle                            

What is the difference between jQuery.show() and jQuery.hide()?

David Meador
Updated on 12-Dec-2019 08:38:09

271 Views

jQuery show() methodThe show( speed, [callback] ) method shows all matched elements using a graceful animation and firing an optional callback after completion.Here is the description of all the parameters used by this method −speed − A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).callback − This is optional parameter representing a function to call once the animation is complete.ExampleYou can try to run the following code to learn how to work with show() method:Live Demo           The jQuery Example     ... Read More

Advertisements