Показать сообщение отдельно
  #12 (permalink)  
Старый 30.10.2018, 13:44
Аватар для SuperZen
Профессор
Отправить личное сообщение для SuperZen Посмотреть профиль Найти все сообщения от SuperZen
 
Регистрация: 08.11.2017
Сообщений: 642

index.html
<html>

<head>
  <link id="news" rel="import" href="/news.html" />
</head>

<body>
  <div id="news-placeholder"></div>
  <script>
    var content = document.getElementById('news').import;
    var items = content.getElementsByClassName('news-item')
    items.length && document.getElementById('news-placeholder').appendChild(items[0])
  </script>
</body>

</html>


news.html
<div class="news">
  <div class="news-item">news 1</div>
  <div class="news-item">news 2</div>
  <div class="news-item">news 3</div>
</div>
Ответить с цитированием