Skip to main content
added 11 characters in body
Source Link
ashleedawg
  • 21.2k
  • 9
  • 78
  • 113

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

function go1() { $("#demo""#demo1").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); } 

function go2() { $('#demo2').delay(100).fadeOut().fadeIn('slow') }
#demo1,  
#demo2 {
  text-align: center;
  font-family: Helvetica;
  background: IndianRed;
  height: 50px;
  line-height: 50px;
  width: 150px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button onclick="go1()">Click Me</button>
<div id='demo1'>My Element</div>
<br>
<button onclick="go2()">Click Me</button> (from comment)
<div id='demo2'>My Element</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

function go1() { $("#demo").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); }
function go2() { $('#demo2').delay(100).fadeOut().fadeIn('slow') }
#demo1, #demo2 {
  text-align: center;
  font-family: Helvetica;
  background: IndianRed;
  height: 50px; line-height: 50px;
  width: 150px;
}
<button onclick="go1()">Click Me</button>
<div id='demo1'>My Element</div>
<br>
<button onclick="go2()">Click Me</button> (from comment)
<div id='demo2'>My Element</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

function go1() { $("#demo1").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100)} 

function go2() { $('#demo2').delay(100).fadeOut().fadeIn('slow') }
#demo1, 
#demo2 {
  text-align: center;
  font-family: Helvetica;
  background: IndianRed;
  height: 50px;
  line-height: 50px;
  width: 150px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button onclick="go1()">Click Me</button>
<div id='demo1'>My Element</div>
<br>
<button onclick="go2()">Click Me</button> (from comment)
<div id='demo2'>My Element</div>

added snippet
Source Link
ashleedawg
  • 21.2k
  • 9
  • 78
  • 113

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

function go1() { $("#demo").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); }
function go2() { $('#demo2').delay(100).fadeOut().fadeIn('slow') }
#demo1, #demo2 {
  text-align: center;
  font-family: Helvetica;
  background: IndianRed;
  height: 50px; line-height: 50px;
  width: 150px;
}
<button onclick="go1()">Click Me</button>
<div id='demo1'>My Element</div>
<br>
<button onclick="go2()">Click Me</button> (from comment)
<div id='demo2'>My Element</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

function go1() { $("#demo").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100); }
function go2() { $('#demo2').delay(100).fadeOut().fadeIn('slow') }
#demo1, #demo2 {
  text-align: center;
  font-family: Helvetica;
  background: IndianRed;
  height: 50px; line-height: 50px;
  width: 150px;
}
<button onclick="go1()">Click Me</button>
<div id='demo1'>My Element</div>
<br>
<button onclick="go2()">Click Me</button> (from comment)
<div id='demo2'>My Element</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

First fadeIn is not required, since element has opacity of 100% by default.
Source Link

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

My way is .fadein, .fadeout .fadein, .fadeout ......

$("#someElement").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
I added a fadeIn at the end because most of the time we what the element stay in the page.
Source Link
etlds
  • 5.9k
  • 2
  • 24
  • 30
Loading
Added code example.
Source Link
Dan Atkinson
  • 11.6k
  • 14
  • 84
  • 116
Loading
Source Link
etlds
  • 5.9k
  • 2
  • 24
  • 30
Loading