I need a javascript to show me the nth-child number when I click a li. For example if I click "apple" console.log show me "2". I want to turn nth-child number into a variable.
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
li:nth-child(1) b {color: #eeaa33;}
li:nth-child(2) b {color: #0000ff;}
li:nth-child(3) b {color: #ff3300;}
</style>
</head>
<body>
<ul class="menu">
<li><b>apple</b></li>
<li><b>watermelon</b></li>
<li><b>blueberry</b></li>
</ul>
<script>
//I need a javascript to show me the nth-child number when I click a li.
//For example if I click "apple" console.log show me "2".
// I want to turn nth-child number into a variable.
</script>
</body>
</html>