嗨我在Javascript中创建一个新的音频标签元素这是代码:
var audio = document.createElement("audio");
audio.setAttribute("id","myid");
audio.setAttribute("autoplay","autoplay");
document.body.appendChild(audio);
Run Code Online (Sandbox Code Playgroud)
在将它附加到身体之前,我想放置一个被触发的事件处理程序,我尝试过这样的事情:
audio.onended = foo;
Run Code Online (Sandbox Code Playgroud)
其中foo类似于:function foo(){alert('Hola')}
和
audio.setAttribute("onended","foo()");
Run Code Online (Sandbox Code Playgroud)
在这两种情况下它都不起作用.在第一种情况下,音频标签被附加而没有任何onended事件处理程序; 而在第二种情况下,附加了音频标签,onended事件在属性上,但它不会触发.
有人有什么想法?
提前致谢.
-Z-
1)在使用行编辑视图时:
@Html.TextArea(name: "Message", rows: 10, columns: 40)
Run Code Online (Sandbox Code Playgroud)
我在编译时收到此错误:
ERR: "The best overload for 'TextArea' does not have a parameter of type 'rows'"
Run Code Online (Sandbox Code Playgroud)
即使有一个以行和列为参数的签名.
2)所以我尝试使用签名:@ Html.TextArea(字符串名称,对象htmlAttributes)
调用函数如下
@Html.TextArea(name: "Message", new { rows=10, columns=40 }
Run Code Online (Sandbox Code Playgroud)
但我得到另一个错误:
ERR: "Named Argument Specifications must appear after all fixed arguments have been specified"
Run Code Online (Sandbox Code Playgroud)
谁知道为什么以及如何解决它们?
先感谢您!
我试图找出一种很好的方法来检查一个字符串是否只包含数字.这是我的努力的结果,但它似乎真的很冗长:
let isDigit c = Char.IsDigit c
let rec strContainsOnlyNumber (s:string)=
let charList = List.ofSeq s
match charList with
| x :: xs ->
if isDigit x then
strContainsOnlyNumber ( String.Concat (Array.ofList xs))
else
false
| [] -> true
Run Code Online (Sandbox Code Playgroud)
例如,我必须将字符串转换为字符列表然后返回字符串似乎真的很难看.你能想出更好的解决方案吗?
我正在尝试在Haskell中制作一个小程序.我需要做的是检查Haskell解释器是否已成功执行bash命令.让我们说"伪代码":
$import System
$if( system "ls" ) has been succesfully run
$then doStuff
Run Code Online (Sandbox Code Playgroud)
你会如何在Haskell中编写这段代码?