www.webdeveloper.com
Results 1 to 4 of 4

Thread: Why won't my page change languages when I click a flag icon?

  1. #1
    Join Date
    May 2013
    Posts
    1

    Smile Why won't my page change languages when I click a flag icon?

    I would like the language to change when a different flag icon is clicked but somehow I don't think my jquery is correct because it's not working. Any guidance would be great.

    Thanks!

    <!doctype html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Mini-Coding Assessment 5</title>
    <script src="//ajax.googleapis.com/ajax/libs/jqu… jquery.min.js"></script>

    <script>
    $(document).ready(function(){
    $("#images/us.png").click(function(){
    $("en").hide();
    });
    });
    </script>

    </head>

    <body>

    <img src="images/us.png"</a>

    <img src="images/it.png"</a>

    <img src="images/es.png"</a>

    <h1>How to Care for Your Cat</h1>

    <ul>

    <li>
    <div lang="en">Make sure that you take your cat to the vet regularly for any vaccinations needed, and just a general checkup to see how your kitty is doing. If you notice anything different with your cat, such as the way they're meowing, walking, eating or acting, and are worried, take your cat to the vet. Sickness nipped in the bud is the best kind.</li></div>

    <li>
    <div lang="it">Assicurarsi che si prende il gatto dal veterinario regolarmente per eventuali vaccinazioni necessarie, e solo un controllo generale per vedere come sta facendo il vostro micio. Se si nota qualcosa di diverso con il vostro gatto, come ad esempio il modo in cui sono miagolando, camminare, mangiare o di agire, e sono preoccupati, prendere il vostro gatto dal veterinario. Malattia stroncata sul nascere è il miglior tipo.</li></div>

    <li>
    <div lang="es">Asegúrese de llevar a su gato al veterinario regularmente para cualquier vacuna necesaria y un chequeo general, para ver cómo su gatito está haciendo. Si nota algo diferente con su gato, como la forma en que está maullando, caminar, comer o actuando, y están preocupados, llevar a su gato al veterinario. Enfermedad cortado de raíz es la mejor clase.</li></div>

    </ul>

    </body>
    </html>

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    1. //ajax.googleapis.com/ajax/libs/jqu… jquery.min.js can you open this address?
    2. $("#images/us.png") can you explain what does it mean?
    3. <img src="images/us.png"</a> wtf is this?!

  3. #3
    Join Date
    Mar 2011
    Posts
    1,147
    Padonak is on the right track.

    I don't really use jQuery, but what I know of it says your code is incorrect and so is your HTML. First, you need to add an 'id' attribute to either the opening <a>nchor tag (which I assume you trimmed off for posting here) or the <img> tags and the <div> tags as well. And then you need to change your JavaScript to point to the identified elements. So, you end up with something like:
    Code:
    <img src="images/us.png" id="flagUS"></a>
    
    <img src="images/it.png" id="flagItaly"></a>
    
    <img src="images/es.png" id="flagSpain"></a>
    .
    .
    <div lang="en" id="en">Make sure that you take your cat to the vet regularly for any vaccinations needed, and just a general checkup to see how your kitty is doing. If you notice anything different with your cat, such as the way they're meowing, walking, eating or acting, and are worried, take your cat to the vet. Sickness nipped in the bud is the best kind.</div>
    </li>
    <li>
    <div lang="it" id="it">Assicurarsi che si prende il gatto dal veterinario regolarmente per eventuali vaccinazioni necessarie, e solo un controllo generale per vedere come sta facendo il vostro micio. Se si nota qualcosa di diverso con il vostro gatto, come ad esempio il modo in cui sono miagolando, camminare, mangiare o di agire, e sono preoccupati, prendere il vostro gatto dal veterinario. Malattia stroncata sul nascere è il miglior tipo.</div>
    </li>
    <li>
    <div lang="es" id="es">Asegúrese de llevar a su gato al veterinario regularmente para cualquier vacuna necesaria y un chequeo general, para ver cómo su gatito está haciendo. Si nota algo diferente con su gato, como la forma en que está maullando, caminar, comer o actuando, y están preocupados, llevar a su gato al veterinario. Enfermedad cortado de raíz es la mejor clase.</div>
    </li>
    and change your JavaScript to something like:
    Code:
    <script>
    $(document).ready(function(){
    $("#flagUS").click(function(){
    $("#en").hide();
    });
    });
    </script>
    Someone else will chime in if I got the JavaScript wrong, but that's the idea. And start making it a habit of running your HTML through the validator at http://validator.w3.org. You need proper HTML or you'll always have problems.

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    here is working version take it as a draft

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles