我有这段代码可以在 CommonJS 上运行,但我想将我的项目切换到 ES6,但我得到的错误是.bindisn\xe2\x80\x99t 函数,所以我想知道是否有人知道我如何切换它超过。
for (const file of player) {\n const event = import(`./player/${file}`);\n\n Storage.player.on(file.split(".")[0], event.bind(null, client));\n}\nRun Code Online (Sandbox Code Playgroud)\n 我只需要将这个数组的数字求和,reduce但是我不知道怎么做。
这是我的代码和尝试:
let arr = [1,2,3,4,6,true,"Dio Brando", false,10,"yare yare"];
let sum = arr.reduce((a.b)=> typeOf.a =="number" && typeOf.b =="number"? a+b :false)
console.log(sum);
Run Code Online (Sandbox Code Playgroud) 我正在尝试以编程方式在Google Chrome浏览器的控制台上单击一个按钮。我尝试了许多不同的方法,但是没有任何效果。
HTML看起来像这样:
<button class="btn-standard call-to-action">Suchen</button>
Run Code Online (Sandbox Code Playgroud)
我可以使用右键getElementsByTagName:
document.getElementsByTagName('button')[20]
// => <button class=?"btn-standard call-to-action">?Suchen?</button>?
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试执行单击时,看起来像这样,什么也没发生;该按钮未单击:
document.getElementsByTagName('button')[20].click
// => ƒ click() { [native code] }
Run Code Online (Sandbox Code Playgroud)
如何执行该按钮的单击?
有人可以解释为什么'12:34' < '123:45'会这样false吗?
console.log('12:34' < '123:45' ? 'true' : 'false')Run Code Online (Sandbox Code Playgroud)
已弃用的 CustomEvent.initCustomEvent() 如何替换以改进旧代码。
我正在处理html文档,并且只想使<p>标签中的一个单词具有不同的颜色。无需制作完全不同的<p>标签,是否有可能?
<!-- Example -->
<p>I want to make only THIS word blue.</p>
<!-- My only solution -->
<p style="display:inline;">I want to make only </p><p style="display:inline; color:blue;">THIS</p><p style="display:inline"> word blue</p>Run Code Online (Sandbox Code Playgroud)
必须有一种更好的方法。
我正在制作一个搜索栏,并且我遇到了一个奇怪的错误,这个错误还没有被同一错误的其他帖子解决.我有一个数组,我forEach用来登录控制台,具体取决于index数组.但是,我收到此错误:
TypeError: undefined is not an object (evaluating 'sites[index].indexOf')
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
var sites = ["Website 1", "Website 2", "Youtube Test Page", "Go to google", "testing for foreward slashes", "MORE!!! :)", "beachballs", "test2", "Good Luck"];
function search() {
var input = $("#searchBar")[0].value;
sites.forEach(function(index) {
console.log(input);
if (sites[index].indexOf(input) != -1) {
console.log("yay");
}
})
}
Run Code Online (Sandbox Code Playgroud)
这是我的搜索栏:
<input type="text" placeholder="Search the web" id="searchBar" onkeyup="search()"/>
Run Code Online (Sandbox Code Playgroud)
我做了很多研究无济于事,所以我很感激一些帮助.
假设我有一个4分钟的视频,我希望它从第25秒而不是从头开始播放.
<video autoplay loop id="bgvid">
<source src="back.mp4" type="video/mp4">
</video>
Run Code Online (Sandbox Code Playgroud) 我想在按下"enter"键时触发一个事件.我使用下面的代码,但它不工作,我不知道为什么.我到处搜索,我发现了这段代码.
<html>
<head>
<script src="jquery.js"></script>
<script src="jquery2.js"></script>
$('#mess').keypress(function(e){
var key= e.which;
if( key == 13){
$('#anc').click();
return false;
}
</head>
<body>
<form>
<a href="#" id="anc" onclick="start()" > Send</a>
<input id="mess" style="width:200px" type="text" name="msg"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) javascript ×8
html ×4
ecmascript-6 ×2
arrays ×1
commonjs ×1
comparison ×1
css ×1
dom ×1
dom-events ×1
foreach ×1
html5 ×1
html5-video ×1
jquery ×1
php ×1
reduce ×1
string ×1
sum ×1
video ×1