I have this code, I want to add the display property to div when test() function fired. I call the function many times in the same file and want it to work for each button individually.
At the moment, if I click on any button it adds the CSS to first inline-data div, not the one I clicked for. What do I need to change so that it works for the inline-data that matches with the button?
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>
.inline-data {
display: none;
}
</style>
</head>
<body>
<table>
<tr>
<td>data 1</td>
<td>
<span>data 2</span>
<div class="inline-data">
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet.</p>
</div>
</td>
<td><button onclick="test()">Click</button></td>
</tr>
<tr>
<td>data 1</td>
<td>
<span>data 2</span>
<div class="inline-data">
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet.</p>
</div>
</td>
<td><button onclick="test()">Click</button></td>
</tr>
<tr>
<td>data 1</td>
<td>
<span>data 2</span>
<div class="inline-data">
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet.</p>
</div>
</td>
<td><button onclick="test()">Click</button></td>
</tr>
</table>
<script>
function test() {
document.querySelector(".inline-data").style.display = "flex";
}
</script>
</body>
</html>
$(".inline-data").css('display', 'flex');.inline-dataelement?