Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
How to fadeIn text stored in a variable when clicking a button, using jQuery

I am trying to fadeIn some text which is stored in a variable that I want to show when a button is clicked. The code below works for the showing part but I can't figure out how to make it fadeIn.

<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <title>Fade in text example</title>
</head>
<body>  

    <div><button id ="button">Click to show text</button></div><br />
    <div id="txtDiv"></div>

    <script>
        $(document).ready(function(){
            var txt = 'Show this stored text.';
            $('#button').on('click', function() {
                $('#txtDiv').text(txt);
            });
        });
    </script>

</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

<script>
    $(document).ready(function(){
        var txt = 'Show this stored text.';
        $('#txtDiv').hide();
        $('#button').on('click', function() {              
          $('#txtDiv').text(txt);
          $('#txtDiv').fadeIn( 600 );
        });
    });
</script>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!