Skip to content Skip to sidebar Skip to footer

Delay Changing InnerHTML Text Using JQuery

So I've got a pretty simple button that basically toggles a form on and off - we'll be using this on our site since we're doing an update and would like feedback available on any p

Solution 1:

You can achieve this by using setTimeout():

var timeout;
$('#feedbackLink').hover(
    function() {
        clearTimeout(timeout);
        timeout = setTimeout(function() {
            $("#feedbackLink").html('Send us a quick message!');
        }, 2000); // change the HTML after 2 seconds
    },
    function() {
        clearTimeout(timeout);
        timeout = setTimeout(function() {
            $("#feedbackLink").html('How can we improve this page?');
        }, 2000); // change the HTML after 2 seconds
    }
);

Solution 2:

How about this:

   $(document).ready(function() {

      function changeText(){
        $("#myDiv").text('test')
      }

      setTimeout(changeText, 2000);

    });

Post a Comment for "Delay Changing InnerHTML Text Using JQuery"