Good morning everyone,
I have a problem when displaying a table in html, I want to add an effect while it is displaying for example I am using
$ ("# delayed"). click (function () { $ ("tr"). delay (1000) .show ("slow"); })
But the time it displays the table it goes fast and n comes with the effect below the code in HTML, JS and CSS.
$(document).ready(function(){
$("button").click(function(){
$("#hide").click(function(){
$("p").delay(200).hide("slow");
})
$("#show").click(function(){
$("p").delay(200).show("slow");
})
$("#delayed").click(function(){
$("tr").delay(1000).show("slow");
})
$.get("https://jsonplaceholder.typicode.com/users", function(dado){
var i;
out = "<table border='0'>";
for(i = 0; i < dado.length; i++){
out+= "<tr id='delayed'><td>"+dado[i].id+"</td>";
out+= "<td>"+dado[i].name+"</td>";
out+= "<td>"+dado[i].email+"</td></tr>";
}
out += "</table>"
document.getElementById("teste").innerHTML = out;
});
});
});
*{
margin:0;
padding:0;
font-family: 'Lato', sans-serif;
}
h1{
color: #fd9500;
}
header{
position: fixed;
width: 100%;
height: 100%;
background-color: #ffffff;
top:0;
left:0;
text-align:center;
}
.button{
border: none;
color: #daf5ff;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
transition-duration: 0.4s;
background-color: #0022ff;
}
.button span{
cursor: pointer;
display: inline-block;
position: relative;
transition: 1s;
}
.button span:after{
content: '<!DOCTYPE HTML>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><scriptsrc="functionJS.js"></script>
<head>
<meta charset="UTF-8">
<title>Treinamento Front-End</title>
<link href="http://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext" rel="style" type="text/css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Lista de Pessoas</h1>
<button class="button"><span>Get Back Requests</span></button>
<button class="button" id="hide"><span>Hide Request</span></button>
<button class="button" id="show"><span>Show Requests</span></button>
<p id="teste"></p>
</header>
</body>
</html>
bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span{
cursor: pointer;
display: inline-block;
position: relative;
transition: 1s;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
table{
border-collapse: collapse;
width: 100%;
}
th, td{
border-bottom: 1px solid #8578f7;
padding: 8px;
text-align: center;
color: #fd9500;
}
$(document).ready(function(){
$("button").click(function(){
$("#hide").click(function(){
$("p").delay(200).hide("slow");
})
$("#show").click(function(){
$("p").delay(200).show("slow");
})
$("#delayed").click(function(){
$("tr").delay(1000).show("slow");
})
$.get("https://jsonplaceholder.typicode.com/users", function(dado){
var i;
out = "<table border='0'>";
for(i = 0; i < dado.length; i++){
out+= "<tr id='delayed'><td>"+dado[i].id+"</td>";
out+= "<td>"+dado[i].name+"</td>";
out+= "<td>"+dado[i].email+"</td></tr>";
}
out += "</table>"
document.getElementById("teste").innerHTML = out;
});
});
});