[an error occurred while processing this directive] [an error occurred while processing this directive]

Javascript – Divers

Copier un élément dans le presse-papier

Publier par Michel PIALLIER dans Javascript - Divers Commentaires fermés sur Javascript – Copier un élément dans le presse-papier

Ajouter un fichier CSS

On veut ajouter un lien avec un fichier CSS dans l’entête

Index.html


<!doctype html>

<html lang='fr'>

<head>

<meta charset='utf-8'>

<title>Importer un fichier CSS</title>

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'> </script>

</head> <body> <div> <p class="rouge">Ce paragraphe est coloré en rouge</p> <p class="vert">Ce paragraphe est coloré en vert</p> </div> </body>

</html>

script.js


$('head').append('<link rel="stylesheet" type="text/css" href="style.css" >');

variante :


var lien =$("<link>");

$('head').append(lien);

lien.attr({

rel:"stylesheet",

type:"text/css",

href:"style.css"

});

style.css


.rouge {
	color:red;
}
.vert {
	color:green;
}

Publier par Michel PIALLIER dans Javascript - Divers Commentaires fermés sur Javascript – Ajouter un fichier CSS
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive]