在 php 循环中隐藏所有 iframe 的元素

Hide elements of all iframes in php loop

有人可以帮我隐藏所有 iframe 的元素吗?现在该功能仅更改我的第一个 iframe。请在下面查看我的代码。

     <script>
      function hideIt(){ 
          document.getElementById('iframe').contentWindow.document.getElementById('editor').style.display = 'none';
          document.getElementById('iframe').contentWindow.document.getElementById('heading').style.display = 'none'; 
          document.getElementById('iframe').contentWindow.document.getElementById('deltimer').style.display = 'none';
          document.getElementById('iframe').contentWindow.document.getElementById('img').style.margin = '20px';} 
</script>
<script>window.onload = hideIt;</script>
<?php
$sql = "SELECT distinct journeyid,image FROM comments WHERE uid=2";
$result = $conn->query($sql);
    while($row = mysqli_fetch_array($result)){
        $url = $row['journeyid'];
        $image = $row['image'];
        echo "<div class='column'>";
        echo "<iframe id='iframe' style='width: 350px; height:400px' src='https://xn--p1aaa84fbaab.net/newjourney.php?journeyid=$url&image=$image'></iframe>
        <a href='https://xn--p1aaa84fbaab.net/newjourney.php?journeyid=$url&image=$image'><br>
        <button type='submit' style='color:black' class='hbutton' name ='editJourney'>Edit</button></a>
        <button type='submit' class='hbutton' name ='forkJourney'>Fork</button>
        <button type='submit' class='hbutton' name ='deleteJourney'>Delete</button>
        <button type='submit' class='hbutton' name ='shareJourney'>Share</button>
        </div>";}?> 
</div>

有解决办法:

<script>
 function hideIt(){ 
   for( let {contentWindow: {document: iframeDoc}} of document.querySelectorAll('.iframe') ) {
      iframeDoc.querySelector('#editor').hidden = true;
      iframeDoc.querySelector('#heading').hidden = true;
      iframeDoc.querySelector('#deltimer').hidden = true;
      iframeDoc.querySelector('#img').style.margin = '20px';
   }
 } 
</script>
<script>window.onload = hideIt;</script>
<?php
$sql = "SELECT distinct journeyid,image FROM comments WHERE uid=2";
$result = $conn->query($sql);
while($row = mysqli_fetch_array($result)){
  $url = $row['journeyid'];
  $image = $row['image'];
  echo "<div class='column'>";
  // Change 'id' attribute to 'class' for ability of query all required iframes 
  echo "<iframe class='iframe' style='width: 350px; height:400px' src='https://xn--p1aaa84fbaab.net/newjourney.php?journeyid=$url&image=$image'></iframe>
            <a href='https://xn--p1aaa84fbaab.net/newjourney.php?journeyid=$url&image=$image'><br>
            <button type='submit' style='color:black' class='hbutton' name ='editJourney'>Edit</button></a>
            <button type='submit' class='hbutton' name ='forkJourney'>Fork</button>
            <button type='submit' class='hbutton' name ='deleteJourney'>Delete</button>
            <button type='submit' class='hbutton' name ='shareJourney'>Share</button>
            </div>";}?> 
    </div>