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>
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
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>
$('#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: { ...
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 ...
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 ...
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,...