• Demonstrate fadeIn() with different parameters.





     
     

  • jQuery événement Méthodes


  • Résultat de l'exemple

    Go on... press the button!

    Go on... hover over me!
    Go on... click me (and hold the mouse down)!

    Go on... press the button!


  • Signets avec ID et  des liens

    Les signets HTML sont utilisés pour permettre aux lecteurs de passer à des parties spécifiques d'une page Web.Les signets peuvent être utiles si votre page Web est très longue.Pour un signet, vous devez d'abord créer le signet, puis ajouter un lien vers elle.Lorsque le lien est cliqué, la page défile à l'emplacement avec le signet.

     

     Exemple

    Tout d' abord, créer un signet avec l' id attribut:

    <h2 id="C4">Chapter 4</h2>

    Ensuite, ajoutez un lien vers le signet ( « Aller au chapitre 4 »), à partir de la même page:

    <a href="#C4">Jump to Chapter 4</a>

    Ou, ajouter un lien vers le signet ( « Aller au chapitre 4 »), d'une autre page:

    <a href="html_demo.html#C4">Jump to Chapter 4</a>

    Exemple 

    <!DOCTYPE html>
    <html>
    <body>
    <p><a href="#C4">Jump to Chapter 4</a></p>
    <h2>Chapter 1</h2>
    <p>Initiation au HTML</p>
    <h2>Chapter 2</h2>
    <p>Initiation au JavaScript</p>
    <h2>Chapter 3</h2>
    <p>Initiation au CSS</p>
    <h2 id="C4">Chapter 4</h2>
    <p>Langage de programmation</p>
    <h2>Chapter 5</h2>
    <p>Quizz</p>
    </body>
    </html>

    Résultat de l'exemple

    Jump to Chapter 4

    Chapter 1

    Initiation au HTML

    Chapter 2

    Initiation au JavaScript

    Chapter 3

    Initiation au CSS

    Chapter 4

    Langage de programmation

    Chapter 5

    Quizz

     

    Utilisation de l'attribut id en JavaScript

    JavaScript peut accéder à un élément avec un id spécifié à l'aide de la getElementById()méthode:

    Utilisez l'attribut id pour manipuler le texte avec JavaScript:

    <script>
    function displayResult() {
        document.getElementById("myHeader").innerHTML = "Have a nice day!";
    }
    </script>

    Exemple 

    <!DOCTYPE html>
    <html>
    <body>

    <h2>Utilisation de l'attribut id en Javascript</h2>
    <p>JavaScript  peut accéder à un  élément avec la méthode getElementById() :</p>

    <h1 id="myHeader">Bonjour tout le monde</h1>
    <button onclick="displayResult()">Change text</button>

    <script>
    function displayResult() {
    document.getElementById("myHeader").innerHTML = "Bonne journée!";
    }
    </script>

    </body>
    </html>

    Résultat de l'exemple

    Utilisation de l'attribut id en Javascript

    JavaScript peut accéder à un élément avec la méthode getElementById() :

    Bonjour tout le monde


  • L' id attribut, spécifie un identifiant unique pour un élément HTML (la valeur doit être unique dans le document HTML).

    La valeur identifiant peut être utilisé par CSS et JavaScript pour effectuer certaines tâches pour un élément unique avec l'identifiant spécifié.

    Dans CSS, pour sélectionner un élément avec un identifiant spécifique, écrire un dièse (#) caractère, suivi de l'ID de l'élément:

    ""

    Exemple simplifié

     <style>

    #myHeader {

        background-color: lightblue;
        color: black;
        padding: 40px;
        text-align: center;

    </style>
    <h1 id="myHeader">My Header</h1>

     Exemple 

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    #myHeader {
    background-color: lightblue;
    color: black;
    padding: 40px;
    text-align: center;
    }
    </style>
    </head>
    <body>

    <h2>The id Attribute</h2>
    <p>Use CSS to style an element with the id "myHeader":</p>

    <h1 id="myHeader">My Header</h1>

    </body>
    </html>

    Résultat Exemple

    The id Attribute

    Use CSS to style an element with the id "myHeader":

    My Header

    Astuce: L'attribut id peut être utilisé sur tout élément HTML.

    Remarque: La valeur id est sensible à la casse.

    Remarque: La valeur id doit contenir au moins un caractère, et  ne doit pas contenir des espaces (espaces, onglets, etc.).

     

    Différence entre la classe et l'ID

    Un élément HTML ne peut avoir qu'un identifiant unique qui appartient à cet élément unique, alors qu'un nom de classe peut être utilisé par plusieurs éléments:

    Exemple simplifié   

    <style>
    /* Style the element with the id "myHeader" */
    #myHeader {
        background-color: lightblue;
        color: black;
        padding: 40px;
        text-align: center;
    }

    /* Style all elements with the class name "city" */
    .city {
        background-color: tomato;
        color: white;
        padding: 10px;

    </style>

    <!-- A unique element -->
    <h1 id="myHeader">My Cities</h1>

    <!-- Multiple similar elements -->
    <h2 class="city">London</h2>
    <p>London is the capital of England.</p>

    <h2 class="city">Paris</h2>
    <p>Paris is the capital of France.</p>

    <h2 class="city">Tokyo</h2>
    <p>Tokyo is the capital of Japan.</p>

    Exemple  

    <!DOCTYPE html>
    <html>
    <head><style>
    /* Style the element with the id "myHeader" */
    #myHeader {
        background-color: lightblue;
        color: black;
        padding: 40px;
        text-align: center;
    }

    /* Style all elements with the class name "city" */
    .city {
        background-color: tomato;
        color: white;
        padding: 10px;

    </style>

    </head>
    <body>

    <h2>Difference Between Class and ID</h2>
    <p>An HTML page can only have one unique id applied to one specific element, while a class name can be applied to multiple elements.</p>

    <!-- A unique element -->
    <h1 id="myHeader">My Cities</h1>

    <!-- Multiple similar elements -->
    <h2 class="city">London</h2>
    <p>London is the capital of England.</p>

    <h2 class="city">Paris</h2>
    <p>Paris is the capital of France.</p>

    <h2 class="city">Tokyo</h2>
    <p>Tokyo is the capital of Japan.</p>

    </body>
    </html>

    Résultat de l'exemple

    Difference Between Class and ID

    An HTML page can only have one unique id applied to one specific element, while a class name can be applied to multiple elements.

    My Cities

    London

    London is the capital of England.

    Paris

    Paris is the capital of France.

    Tokyo

    Tokyo is the capital of Japan.





    Suivre le flux RSS des articles de cette rubrique