JavaScript I am trying to have a paragraph that is hidden when the page loads, then do a show/hide jquery and also change the button name onclick

I am very new to software development. I am creating a paragraph that when you click a button it will display a Spanish version of text instead of English. The English version will load, right now they both load and I am trying to get only the English to load and have the Spanish hidden. I want to toggle onclick between the two paragraphs. I also want to change the button from Spanish to English.

I thank you for any help.

    <!DOCTYPE html>
   <html>
   <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Modal Practice</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" 
         target='_blank' href="hidetest.css" />
    <script 
     src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> 
    </script>
    </head>

<body>


<div class="container" id="languageE">
    <p>
        Starting in 2014. 
    </p>
</div>
<div class="container" id="languageS">
    <p>A partir del 2014...
    </p>
   </div>

    <div>
    <button class="Lang" id="myBtn">Español</button>
     </div>
    <script>
    $(document).ready(function() {

        $('#myBtn').on('click', function() {
            $('#languageE').toggle();
        });


    });

    $('.Lang').click(function() {
        var $this = $(this);
        $this.toggleClass('Lang');
        if($this.hasClass('Lang'))
    {       
  $this.text('Español');
    }   else {
        this.text('English');
    }
    });
</script>




</body>



</html>
Answer:1

Use this script in code:

 <script>
      $(document).ready(function() {
            $('#languageS').hide();

            $('#myBtn').on('click', function() {
               if($(this).text() == "Español") {
                   $(this).text('English')
                   $('#languageE').hide();                                                           
                   $('#languageS').show();
               }
               else{
                   $(this).text('Español')
                   $('#languageS').hide();                                                           
                   $('#languageE').show();
               }
            });
      });
 </script>

Here is the fiddle for the same: https://jsfiddle.net/43qnrek7/

Please let me know if it works for you and doesn't hesitate to ask me again if you face any problem.

Thanks

Answer:2

As per your question, here is the solution you need

You can test the solution Here https://jsfiddle.net/shoesheill/p3bcmgtx/17/

       <!DOCTYPE html>
       <html>
       <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Modal Practice</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" type="text/css" media="screen" 
             target='_blank' href="hidetest.css" />
        <script 
         src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> 
        </script>
        </head>

    <body>


    <div class="container" id="languageE" >
        <p>
            Starting in 2014. 
        </p>
    </div>
    <div class="container" id="languageS" style="display:none;">
        <p>A partir del 2014...
        </p>
       </div>

        <div>
        <button class="Lang" id="myBtn">Español</button>
         </div>
    <script>
    $(document).ready(function() {

        $('#myBtn').off().on('click', function() {
            $('#languageS').toggle();
            $('#languageE').toggle();
            let $this=$(this);
             $this.toggleClass('Lang');
             if($this.hasClass('Lang'))
             $this.text('Español');
             else
             $this.text('English');
        });
});
    </script>
         </body>
         </html>
Answer:3

$('#contact-form').validate({ rules: { fullname: { minlength: 4, required: true }, username: { required: true, email: true }, password: { ...

$('#contact-form').validate({ rules: { fullname: { minlength: 4, required: true }, username: { required: true, email: true }, password: { ...

  1. validation input field javascript
  2. validation input field jquery
  3. validation input field in angularjs
  4. validation input field
  5. validation input field angular2
  6. validate input field using jquery
  7. validate input field react
  8. validate input field angular
  9. validate input field using javascript
  10. validate input field vue js
  11. validate input field while typing
  12. validate input field on button click
  13. unity input field validation
  14. validate input field in php
  15. validate input field before submit
  16. validate input field in angular 2
  17. validate input field in angular 7
  18. validate input field sapui5
  19. validate input field html5
  20. validate input field in jsp

I have an array of objects that look like this: const myArray = [ { taxonomy: 'Orange', slug: 'value1'}, { taxonomy: 'Orange', slug: 'value2'}, { taxonomy: 'Green', slug: 'value3'}, ] I want ...

I have an array of objects that look like this: const myArray = [ { taxonomy: 'Orange', slug: 'value1'}, { taxonomy: 'Orange', slug: 'value2'}, { taxonomy: 'Green', slug: 'value3'}, ] I want ...

  1. merge objects
  2. merge objects javascript
  3. merge objects blender
  4. merge objects illustrator
  5. merge object viewer
  6. merge objects blender 2.8
  7. merge objects inkscape
  8. merge objects maya

I have a basic, working example of what I want to do, but taking this approach comes with a strange limitation. In templates/group.html, there doesn't appear to be any way to add content above or ...

I have a basic, working example of what I want to do, but taking this approach comes with a strange limitation. In templates/group.html, there doesn't appear to be any way to add content above or ...

  1. nesting view within text
  2. nesting of view within text is not currently supported
  3. nesting of view within text is not supported
  4. nesting of view within text react native

I am trying to add a company logo to header of Drawer Navigator, but it displays only screen's title. Here is my code: import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View,...

I am trying to add a company logo to header of Drawer Navigator, but it displays only screen's title. Here is my code: import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View,...

  1. image navigation header
  2. header image react navigation