我的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) {
$("#alerta button").after('<span>Matricula copiada</span>');
$('#alerta').fadeIn('slow');
$('#alerta').setTimeout(close(), 3000);
});
</script>
我身上有div
:
<div class="alert alert-info" id="alerta" style="display: none; ">
<button type="button" class="close"></button>
</div>
但我的setTimeout
无法正常工作。我该怎么办?
答案 0 :(得分:1)
Setimeout应写成如下
$('#alerta').setTimeout(close, 3000);
无括号。
答案 1 :(得分:0)
有身体div
<div class="alert alert-info" id="alert" style="display: none; ">
<button type="button" class="alertaderecha">La matrícula ha sido copiada.</button>
并且有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>
任何答案都在这里问
特别感谢@ Stephen Muecke