eren
eren

Reputation: 45

How to use single head tag for all pages of a web site

What should I do to make the same link tags reachable on each page without being written in their head tags over and over again?

Here is the jQuery snippet that I use to reach 'header' tag everywhere but It doesn't work for the 'head' tag the same way.

<script>
    $.get('header.html', function (response) {
        $('#header').html(response);
    });
</script>
<header id="header"></header>

Upvotes: 1

Views: 915

Answers (2)

Shamim
Shamim

Reputation: 236

You may try this.

let headLinks = `
    <link rel="stylesheet" href="style.css" />
    <link rel="stylesheet" href="one.css" />
    <link rel="stylesheet" href="two.css" />
   `;

  document.querySelector('#html-head').insertAdjacentHTML('beforeend', headLinks);
<head id="html-head">
    ...meta contents...
</head>

Upvotes: 2

Noa
Noa

Reputation: 1216

try this.

$("#someDivID").load("b.html",function(data){
    var value=$(data).find("#elementID").attr("attributeName");
});

Upvotes: 1

Related Questions