I can't figure out why, but scrollIntoView()
function doesn't work in Chrome Version 71.0.3578.98 and I believe in any other either. The browser displays no errors and screen isn't scrolling anywhere. I haven't been able to find any answer in the Internet. Below is simplified code:
// [...]
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Surname</th>
</tr>
</thead>
<tbody>
<?php
if (is_array($array)) {
foreach ($array as $element) { ?>
<tr data-someid="<?= $element->some_id ?>">
<th><?= $element->id ?></th>
<td><?= $element->name ?></td>
<td><?= $element->surname ?></td>
</tr>
<?php }
} ?>
</tbody>
</table>
// [...]
<script>
var url = new URL(window.location.href);
var someId = url.searchParams.get('some_id');
var element= document.querySelector('[data-someid="' + someId + '"]');
console.log(element); // displays the element well
element.scrollIntoView();
</script>
// [...]
Do somebody have any ideas why it doesn't work?
P.S. I am using DataTables to render the table and for convenience didn't display it in the code.