Gerardo Quintana
Gerardo Quintana

Reputation: 61

setTimeout dont works?

My JavaScript code is this one:

<script type="text/javascript">
                        ZeroClipboard.config({ swfPath:     "/Content/ZeroClipboard.swf" });

                        var client = new ZeroClipboard($(".copy-button"));
                        client.on('copy', function (event) {
                            event.clipboardData.setData('text/plain', event.target.innerText);
                        });

                        client.on("aftercopy", function (event) {

                            $("#alerta button").after('<span>Matricula copiada</span>');
                            $('#alerta').fadeIn('slow');
                            $('#alerta').setTimeout(close(), 3000);
                             });
                    </script>

and I have div on body :

  <div class="alert alert-info" id="alerta" style="display: none; ">
     <button type="button" class="close"></button>
         </div>

but my setTimeout doesn't work. What can I do?

Upvotes: 2

Views: 164

Answers (2)

Gerardo Quintana
Gerardo Quintana

Reputation: 61

There is body div

<div class="alert alert-info" id="alert" style="display: none; ">
    <button type="button" class="alertaderecha">La matrícula ha sido    copiada.</button>

and there is javascript:

<script type="text/javascript">
    ZeroClipboard.config({ swfPath: "/Content/ZeroClipboard.swf"});

    var client = new ZeroClipboard($(".copy-button"));

    client.on('copy', function (event) {
        event.clipboardData.setData('text/plain', event.target.innerText);
    });

    client.on("aftercopy", function (event) {
        var message = $("#alert").after('');
        $('#alert').fadeIn('slow');
        var time = setTimeout(function (e) {
            message.hide();
        }, 3000);
    });
</script>

any answer ask here

SPECIAL THANKS TO @ Stephen Muecke

Upvotes: 0

Sukesh Marla
Sukesh Marla

Reputation: 177

Setimeout should be written as follows

$('#alerta').setTimeout(close, 3000);

No Parenthesis.

Upvotes: 1

Related Questions