在 ins 标签内通过 JavaScript 更改值

Changing a value by JavaScript inside a ins tag

<ins class='adsbygoogle'
style='display:block'
data-ad-client='ca-pub-XXXXXXXXXXXXXXX'
data-ad-slot='000000000000'
data-ad-format='auto'
data-full-width-responsive='true'></ins>

我想用 JavaScript 将 data-ad-slot 值更改为 123456789。我怎样才能做到这一点? 这个我试过了~(但是不行)

<ins class='adsbygoogle'
    style='display:block'
    data-ad-client='ca-pub-XXXXXXXXXXXXXXX'
    data-ad-slot=document.write (x);
    data-ad-format='auto'
    data-full-width-responsive='true'></ins>

    <script> var x= 123456789;</script>

设置.dataset.adSlot.

<ins class='adsbygoogle'
    style='display:block'
    data-ad-client='ca-pub-XXXXXXXXXXXXXXX'
    data-ad-format='auto'
    data-full-width-responsive='true'></ins>
<script> 
var x= 123456789;
var elem = document.querySelector('.adsbygoogle');
elem.dataset.adSlot = x;
console.log(elem);
</script>