如果details标签具有open属性,则summary文本将显示“关闭”。
我尝试更改文本:
if (jQuery("details").click().attr("open")) {
jQuery("summary").text("Close");
} else if (jQuery("details").click().attr("")) {
jQuery("summary").text("Show")
}Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<details class="description" open>
<summary class="">Show</summary>
<p class="">Description text</p>
</details>Run Code Online (Sandbox Code Playgroud)
我在 Firefox 中遇到了问题。
这适用于 Chrome、Safari 和移动设备。
当您单击卡片时,它会翻转,但当您单击卡片将其翻转时,您仍然可以看到卡片的“单击翻转”正面部分。它显示为颠倒的文本。我尝试过当卡片 css 具有“翻转”类时将 css 定位为隐藏/显示,但它仍然不会消失。
这又是 Firefox 的问题。任何建议都会很棒。
$('.card').click(function(){
$(this).toggleClass('flipped');
});Run Code Online (Sandbox Code Playgroud)
.card-height2: {
height: 281px;
}
.flip {
-webkit-perspective: 800;
perspective: 800;
position: relative;
cursor: pointer;
}
.flip .card.flipped {
-webkit-transform: rotatex(-180deg);
transform: rotatex(-180deg);
background: transparent;
}
.flip .card {
height: 195px;
-webkit-transform-style: preserve-3d;
-webkit-transition: 0.5s;
transform-style: preserve-3d;
transition: 0.5s;
}
.flip .card .face {
-webkit-backface-visibility: hidden ;
backface-visibility: hidden ;
z-index: 2;
}
.flip .card .front {
position: absolute;
width: 100%;
z-index: 1; …Run Code Online (Sandbox Code Playgroud)我有一个JS文件,我正在从以前的员工那里工作,那里的代码具有如下功能:
funcName: function funcName() {
//Some stuff here
}
Run Code Online (Sandbox Code Playgroud)
我之前从未见过以“ funcName:”开头的函数。
我删除了它,代码仍然有效。
有人可以解释将函数名称作为属性的目的吗?(我假设它是一个属性,因为它具有前导冒号。此函数未包装在其他任何东西中)
我是多维数组的新手,并使用这样的对象来显示数据.我想要实现的是循环并在数组中随机显示一个问题,然后用户将输入"更高或更低"的答案,并将输入值与答案对象相匹配.
目前我只是显示"0"作为我的输出.我假设这与questions.length部分只是一个数组,因为开始括号由对象组成?
如何实现随机问题生成?
如果我需要进一步解释请告诉我,但它应该只是一个简单的问题,并将用户输入的值与答案进行比较,并显示正确或不正确.
$(function() {
function gameStart(){
var questions = [
{
question1: {
question: 'Is the price higher or lower than $40.00?',
answer: 'higher'
},
question2: {
question: 'Is the price higher or lower than $100.00?',
answer: 'higher'
},
question3: {
question: 'Is the price higher or lower than $50.00?',
answer: 'lower'
}
}
];
var i;
for(i = 0; i < questions.length; i++) {
document.getElementById("question").innerHTML = Math.floor(Math.random()*questions.length);
}
}
gameStart();
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<h2 id="question"></h2>
</div> …Run Code Online (Sandbox Code Playgroud)