我正在使用 Java 的 Dreamweaver 中构建一个 Web 程序,并且我正在尝试学习在方法之间传递变量。但是我看的所有教程都涉及参数和公共类,由于某种原因在 Dreamweaver 中没有被识别,还有其他方法吗?我该怎么做呢?
var list = [];
list[0] = [zero]; // USE VARIABLES HERE
list[1] = [one];
list[2] = ["two"];
list[3] = ["three"];
function Make() {
for (var i = 0; i < 4; i++) {
var div = document.createElement("div");
div.style.width = "10px";
div.style.height = "10px";
div.style.background = "white";
div.style.color = "black";
div.style.top = "0px";
div.style.left = "0px";
div.style.margin = "10px 10px auto";
div.style.cursor = "pointer";
div.innerHTML = list[i];
!function() {
var index = 0;
div.onclick = function() {
doSomething(this);
doEverything(this);
};
}();
document.body.appendChild(div);
}
}
function doSomething(element) {
var value = element.innerHTML;
// alert('clicked : '+ value);
switch (value) {
case "zero":
break;
case "one":
//USE VARIABLES HERE
break;
case "two":
alert("go");
break;
case "three":
alert("go");
break;
}
}
$(document).ready(function doEverything(element) {
$.getJSON("https://api.foursquare.com/v2/venues/search?ll=-27.58818,-48.523248&client_id=&client_secret=&v=20111107", function(data) {
var two = data.response.venues[1].name;
var one = data.response.venues[0].name;
// USE THESE VARIABLES
});
});
Make();