您好我可能遗漏了一些非常明显的事情。
我正在尝试制作一个toggleClass,以便将英语的英语翻译成西班牙语。
当我点击西班牙语文本/按钮时,基本上只想显示西班牙语ul,当我点击英文文本/按钮时显示英语ul。
这是jsfiddle https://jsfiddle.net/TonyTheOnly/k92ayp24/
非常感谢任何帮助!
$(document).ready(function(){
$(".burger-nav").on("click", function(){
$("nav ul").toggleClass("open");
});
});
$(document).ready(function () {
$(".spanish").on("click", function () {
$("englishNav").toggleClass("spanishNav");
});
$(".english").on("click", function () {
$("spanishNav").toggleClass("englishNav");
});
});

.spanishNav {
display:none;
}
.spanish{
cursor:pointer;
}
.english{
cursor:pointer;
}
nav {
float: right;
padding-right: 10%
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 35px;
padding-top: 25px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 24px;
}
.burger-nav{
display: block;
height: 40px;
width: 40px;
float: right;
background: url("https://cdn4.iconfinder.com/data/icons/wirecons-free-vector-icons/32/menu-alt-512.png");
background-size: cover;
cursor: pointer;
}
.wrapper {
width: 100%;
padding: 0;
}
nav ul {
overflow: hidden;
background: white;
height:0;
}
nav ul.open {
height: auto;
margin-top:150px;
margin-right: 100px;
}
nav ul li{
float:none;
text-align: left;
width: 100%;
margin: 0;
}
nav ul li a {
color: black;
padding: 10px;
border-bottom: 1px solid #404040;
display: block;
margin: 0;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<nav>
<a class="burger-nav"></a>
<ul class="englishNav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
<ul class="spanishNav">
<li><a href="#">Homeo</a></li>
<li><a href="#">Abouto</a></li>
<li><a href="#">Serviceso</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Contact</a></li>
</ul>
<p class="spanish">
spanish
</p>
<p class="english">
english
</p>
</nav>
</div>
&#13;
答案 0 :(得分:0)
您似乎错误地使用了<DataGrid ColumnWidth="*" ItemsSource="{Binding AllFolders, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
。 toggleClass
用于添加/删除课程。为了达到您想要的效果,我们只需隐藏/显示toggleClass
或.spanishNav
元素,具体取决于所选的语言。
一种解决方案是根据选择的按钮显示/隐藏西班牙语/英语导航元素。像这样:
.englishNav
$(document).ready(function() {
$(".burger-nav").on("click", function() {
$("nav ul").toggleClass("open");
});
$(".spanish").on("click", function() {
$(".englishNav").hide();
$(".spanishNav").show();
});
$(".english").on("click", function() {
$(".englishNav").show();
$(".spanishNav").hide();
});
});
.spanishNav {
display: none;
}
.spanish {
cursor: pointer;
}
.english {
cursor: pointer;
}
nav {
float: right;
padding-right: 10%
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
margin-left: 35px;
padding-top: 25px;
position: relative;
}
nav a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 24px;
}
.burger-nav {
display: block;
height: 40px;
width: 40px;
float: right;
background: url("https://cdn4.iconfinder.com/data/icons/wirecons-free-vector-icons/32/menu-alt-512.png");
background-size: cover;
cursor: pointer;
}
.wrapper {
width: 100%;
padding: 0;
}
nav ul {
overflow: hidden;
background: white;
height: 0;
}
nav ul.open {
height: auto;
margin-top: 150px;
margin-right: 100px;
}
nav ul li {
float: none;
text-align: left;
width: 100%;
margin: 0;
}
nav ul li a {
color: black;
padding: 10px;
border-bottom: 1px solid #404040;
display: block;
margin: 0;
}
答案 1 :(得分:0)
你忘了点
只需将englishNav
更改为.englishNav
,将spanish
更改为.spanish