当我有一个数组时,我的功能不会被调用

时间:2015-05-16 03:08:00

标签: javascript arrays function

出于某种原因,我的功能不会被调用,这是我从开始以来一直这样做的方式!

<h1 id="c"></h1>
<button onClick="new()">n</button>
<script>
    var end = document.getElementById('c');

    var a = ['ur mom', 'The Illuminati', 'A door', 'That shady guy on the corner of the street', 'Windows xp', 'Spodermen', 'Murica', 'Barack Obama', 'Patrick Star', 'Justin Bieber', 'The Game Grumps', 'Pewdiepie', 'A FLUFFY BUNNY'];

    var aX = a[Math.floor(Math.random() * a.length)]

    function new() {
        end.innerHTML = aX;
    }
</script>

1 个答案:

答案 0 :(得分:1)

var getquest = (from q in dc.Exam_Questions where q.ExamNumber == int.Parse(Examnumber) select new { QuestionTitle = q.QuestionTitle, correctanswers = q.correctanswers, ID = q.ID, }); ListView1.DataSource = getquest; ListView1.DataBind(); 是javascript中的保留关键字,您不能将其用作函数签名。更改方法的名称,代码将起作用。

new

<button onClick="myMethod()">n</button>

请参阅此demo