1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div>
<p>Paragraphe 1</p>
<button>clique moi 1</button>
</div>
<div>
<p>Paragraphe 2</p>
<button>clique moi 2</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('button').on('click', function(){
var $that = $(this);
$('p').hide();
$($that).prev('p').show();
});
});
</script>
</body>
</html> |
Partager