I have such a code:
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Click me</button>
<table class="demo">
<div>
<a>link1</a>
<p>text</p>
</div>
</table>
<a>link2</a>
<script>
function myFunction() {
var el = document.getElementsByClassName("demo")[0].getElementsByTagName("a");
for (var i = 0; i < el.length; i++) {
el[i].style.color = "red";
}
}
</script>
</body>
</html>
I would like to change only these links which are inside the table. Is it possible using js? How to do this?

document.querySelectorAll('table.demo a');to get all your links.