โค๊ด:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
button {
-moz-user-select: text;
background: none;
border: none;
color: blue;
cursor: pointer;
font-size: 1em;
margin: 0;
padding: 0;
text-align: left;
}
button.link:hover span {
text-decoration: underline;
}
</style>
<script>
$(document).ready(function(){
$('p').hide();
$("button").click(function(){
var num=$(this).attr('rel');
$( "#p" num ).toggle( "slow", function() {
// Animation complete.
});
});
});
</script>
</head>
<body>
<p id="p1">Show Detaill 1</p>
<button rel="1">Click #1</button><br>
<p id="p2">Show Detaill 2</p>
<button rel="2">Click #2</button><br>
<p id="p3">Show Detaill 3</p>
<button rel="3">Click #3</button><br>
<p id="p4">Show Detaill 1</p>
<button rel="4">Click #4</button>
</body>
</html>
เดาเอาว่าต้องการแบบนี้