相关疑难解决方法(0)

为什么我的JavaScript不能在JSFiddle中运行?

我不知道这个JSFiddle有什么问题.

HTML:

<input type="button" value="test" onclick="test()">
Run Code Online (Sandbox Code Playgroud)

JavaScript的:

function test(){alert("test");}
Run Code Online (Sandbox Code Playgroud)

当我点击按钮时 - 什么也没发生.控制台说"测试未定义"

我已经阅读了JSFiddle文档 - 它说添加了JS代码并添加了<head>HTML代码<body>(所以这个JS代码早于html并且应该工作).

html javascript jsfiddle

113
推荐指数
3
解决办法
5万
查看次数

JavaScript'onclick'事件'返回'关键字功能

我是javascript的新手,偶然发现了return关键字.基本上,这两个陈述的区别是什么?

<input type="checkbox" onclick="doAlert()" />
Run Code Online (Sandbox Code Playgroud)

VS

<input type="checkbox" onclick="return doAlert();" />
Run Code Online (Sandbox Code Playgroud)

从本质上讲,两者都返回了相同的结果并调用了函数,但还有更多吗?任何帮助非常感谢:).谢谢!

html javascript return onclick

47
推荐指数
2
解决办法
8万
查看次数

使用纯javascript删除元素

我试图删除ul(列表项)中的元素,因此只使用javascript.因为我动态生成html,所以我试图设置onclick,因为我在下面创建它.但是,当我尝试单击(请参阅小提琴)时,元素不会被删除.相关功能如下:

var appendHTML = function (el) {
    var list = document.getElementById("events");
    for (var i = 0; i < filteredDates.length; i++) {
        var listItem = filteredDates[i].name;
        listItem.className = "event-list";
        listItem.setAttribute("onclick", "deleteEvent()");
        list.appendChild(listItem);
    }
};


var deleteEvent = function () {
    var listItem = this.parentNode;
    var ul = listItem.parentNode;
    //Remove the parent list item from the ul
    ul.removeChild(listItem);
    return false;
};
Run Code Online (Sandbox Code Playgroud)

https://jsfiddle.net/youngfreezy/7jLswj9b/5/

html javascript

0
推荐指数
1
解决办法
82
查看次数

如何实现Arduino Due的tone()和noTone()?

事实证明,noTone()tone()在核心的arduino API中,但似乎没有Arduino Due实现。我希望使用tone()noTone()实现此处找到的马里奥死亡声音,但是当我添加代码并对其进行编译时,出现以下错误:

trenchRun:154: error: 'tone' was not declared in this scope
trenchRun:156: error: 'noTone' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

如果您有兴趣,这里有一个SSCCE,是在Mac OS X 10.8上针对Arduino 1.5.4编译的:

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  tone(1, 12345, 1000);
}
Run Code Online (Sandbox Code Playgroud)
sketch_oct24a.ino: In function 'void loop()':
sketch_oct24a:7: error: 'tone' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

由于我有Arduino Due,因此我只能使用Arduino 1.5.4。

如何实现Due 的tone()noTone() …

c arduino

-5
推荐指数
1
解决办法
6417
查看次数

标签 统计

html ×3

javascript ×3

arduino ×1

c ×1

jsfiddle ×1

onclick ×1

return ×1