-2

i have a div i.e

<div class="msg-panel" id="mydiv"></div>

CSS code:

 .msg-panel {
        position: absolute;
        height: 35px;
        width: 200px;
        background-color: green;
        top: 30%;
        left: 50%;
        color: #fff;
        display: none;
        border-radius: 20px;
        font-weight: bold;
    }

i want to display this div for ten seconds on button click.

can you help me for this thanks.

Aziz Khan
  • 13
  • 3
  • 1
    what have you tried so far? I see no script that shows that you even attempted to solve this on your own. – tacoshy May 27 '21 at 18:06
  • If you have yet to try anything, check out the [click](https://api.jquery.com/click/) method for listening for the click event when a button is clicked, the [delay](https://api.jquery.com/delay/) method for waiting the 10 seconds, and the [hide](https://api.jquery.com/hide/) method for actually hiding the div. – Daniel Black May 27 '21 at 18:13
  • `$('.msg-panel').show().delay(10000).hide();` – s.kuznetsov May 27 '21 at 18:14
  • Duplicate: https://stackoverflow.com/q/683363/519413 – Rory McCrossan May 27 '21 at 18:37

1 Answers1

0

This should work:

$(function() {
    $(".msg-panel").show()
    setTimeout(function() {
        $(".msg-panel").hide()
    }, 10000);
});
stann
  • 91
  • 5