我正在使用jQuery隐藏div via hide().
然后当点击链接时它会显示div,但由于某种原因它不会停留.它将显示为ms然后消失.
HTML
<div id="introContent">
<h1 id="introText">Welcome</h1>
<p id="introParagraph">I create <strong>Responsive</strong>, <strong>Interactive</strong>, <strong>Beautiful</strong> Mobile ready Websites.
Every Website is created from scratch for each client so no Two Projects are alike.
Please read more about my Company and our work.
"High Quality Work at Affordable Prices"
</p>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$(function() {
$("#introContent").hide();
$("#intro").click(function () { //$(#intro) is a link in my nav bar
$("#introContent").show();
});
});
Run Code Online (Sandbox Code Playgroud) 我在JS中的输出文本之前一直未定义.这是我的代码.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Learning javascript</title>
</head>
<body>
<p id="arrayString"></p>
<!-- Javascript -->
<script type="text/javascript" src="JS/app2.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的JS
var arrayString;
var myArray=["Ms.Vickies", "Old Dutch", "Lays"];
for (var i=0; i<myArray.length; i++) {
arrayString=arrayString+myArray[i];
}
document.getElementById("arrayString").innerHTML=arrayString;
Run Code Online (Sandbox Code Playgroud)
我的输出是 undefinedMs.VickiesOld DutchLays
另外为什么没有空格?我是JS的新手,但我正在努力工作.无法弄清楚这一点.