JavaScript Fade in and fade out text at the same location fade in fade out text premiere pro,fade in fade

I want to write a code which can toggle two sentences fading in and fading out. But I want to toggle the sentences at the same location ie one text fades and the other starts coming in place of the first. In this case the sentences occur one below the other. Is there any way I can do this as in html content always comes one below the other.

This is the jquery script.

<script>
 $(document).ready(function(){
 $(function(){
       $("#hide1").hide();
       while(1)
      {
       $("#hide2").fadeOut(3000);
       $("#hide1").fadeIn(3000);
       $("#hide1").fadeOut(3000);
       $("#hide2").fadeIn(3000);
     }
 });
});
</script>

Html

<p id="hide1"> Hide 1 <p>
<p id="hide2"> Hide 2 <p>
Answer:1

Demo Try like this make the queue and animate

  $("#hide1").hide();

function hide1() {
    $("#hide2").fadeIn(3000);
    $("#hide2").fadeOut(3000, hide2);
}

function hide2() {

    $("#hide1").fadeIn(3000);
    $("#hide1").fadeOut(3000, hide1);
}
hide1();

OR Chaining

$("#hide1").hide();

function hide1() {
    $("#hide2").fadeIn(3000).fadeOut(3000, hide2);
}

function hide2() {
    $("#hide1").fadeIn(3000).fadeOut(3000, hide1);
}
hide1();

This code would react dynamically, and it does not need any changes even if you want to apply this effect for more than two p elements

$("p").hide();

function test(elem) {
    elem.fadeIn(1000, function () {
        elem.fadeOut(1000, function () {
            test(elem.next('p').length ? elem.next('p') : $('p:first'));
        });
    });
}

test($('p:first'));

DEMO

Answer:2

Try this:

setInterval(function () {
    $('#hide1').fadeOut(1000, function () {
        var $this = $(this);
        $this.text($this.text() == 'Hide 2' ? 'Hide 1' : 'Hide 2');
        $this.fadeIn(1000);
    });
}, 3000);

Toggle the text within the setInterval function.

Fiddle Demo

Answer:3

i would like to query mysql database for some result using PHP and display the result in an alert dialog box using javascript. I can connect and query the database ontop on displaying the result in a ...

i would like to query mysql database for some result using PHP and display the result in an alert dialog box using javascript. I can connect and query the database ontop on displaying the result in a ...

  1. display mysql result php
  2. display mysql results in table php
  3. display mysql results in html table
  4. display mysql results in table
  5. echo mysql result
  6. echo mysql result php
  7. display mysql query in html table
  8. display mysql query error php
  9. echo mysql result array
  10. display mysql query in wordpress
  11. display mysql query
  12. mysql display results vertically
  13. mysql display results horizontally
  14. mysql display results
  15. mysql display results in columns
  16. mysql display results in one row
  17. mysql display query time
  18. mysql display query error
  19. display mysql select results in php

For Angular's ng-repeat, I only saw inline equality filters. However, is it possible to inline inequalities as well? This fiddle illustrates my problem: Equality filter works: <div ng-controller="...

For Angular's ng-repeat, I only saw inline equality filters. However, is it possible to inline inequalities as well? This fiddle illustrates my problem: Equality filter works: <div ng-controller="...

  1. ng-repeat filter inline

I cannot for the life of me figure out what is going on here. I'll open a different browser to check if what I changed works, and maybe my other browser cached something, and it will work! But then I ...

I cannot for the life of me figure out what is going on here. I'll open a different browser to check if what I changed works, and maybe my other browser cached something, and it will work! But then I ...

  1. ajax isn't working
  2. ajax is null
  3. ajax isnan
  4. ajax isnumeric
  5. ajax is not sending
  6. ajax insta
  7. isn't ajax

I am working on jquerymobiles. I have to change the order of displaying div depending on change of value in select box html <select class="sel"> <option value="1">one</option>...

I am working on jquerymobiles. I have to change the order of displaying div depending on change of value in select box html <select class="sel"> <option value="1">one</option>...

  1. possible to change the order