0

<header data-role="header">
    <h1> TEA TIME </h1>
    <a href="#home" class="ui-btn ui-btn-icon-top ui-icon-back ui-btn-icon-notext">back</a>
</header>
<h1>Takes 3 Minutes</h1>
<p id="timedisp">120 Sec</p>
<div class="clock">

</div>

<a href="#" id="start">Start</a>
<a href="#" id="reset">Reset</a>

</section>

the below is the html that controls my timer

function greenTea(){

Set The Duration var duration = 120;

Insert the duration into the div with a class of clock
    $(".clock").html(duration + " sec");  


Create a countdown interval

    var countdown = setInterval(function () {

        // subtract one from duration and test to see
        // if duration is still above zero
        if (--duration) {
            // Update the clocks's message
            $(".clock").html(duration + " sec");
        // Otherwise
        } else {

             // Clear the countdown interval
            clearInterval(countdown);
            // set a completed message
            $(".clock").html("End Your Steep");  

        }

    // Run interval every 1000ms 
    }, 1000);

};


$("a#start").click(greenTea)

Why is the below not working? I am trying to get my p#timedisp to disappear when I click the a#start link.

$("p#timedisp").hide(("a#start").click()); 

$('#reset').click(function() {
    location.reload();
});
2
  • 2
    you need to put more code for me to be able to help Commented Apr 10, 2015 at 1:36
  • 1
    More details about your HTML, JS is necessary to answer this question. Please read our Help section on how to create an MCVE (stackoverflow.com/help/mcve) and add it to your question. You will get faster, better help from the community that way. Commented Apr 10, 2015 at 1:36

4 Answers 4

1

Your jQuery should be:

$('#start').click(function(){
    $('#timedisp').hide();
}) 
Sign up to request clarification or add additional context in comments.

Comments

0

You can use something along the lines of this:

$(function() {
  $("p#timedisp").on('click', function() {
    //$("a#start").hide();

    alert('do hide');
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p id="timedisp">120 Sec</p>

Comments

0

IF you included jQuery library this should work

<a id="start" href="#">CLICK ME</a>
<p id="timedisp">120 Sec</p>


<script>
$(function() { // DOM is now ready

    $("#start").click(function( event ) {
        event.preventDefault(); // Prevent default anchor behavior
        $("#timedisp").hide(); 
    });

});
</script>

Comments

0

This would work

 $('#start').on("click",function(){
     document.getElementById('timedisp').style.display = 'none';
      //post code
    })

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.