2016-02-24 90 views
0

我有一个按钮,当它被点击时,我想调用一个函数。现在它只是测试。现在,当我运行它时,按钮看起来似乎不可点击。该按钮没有调用javascript函数

的index.html:

<!DOCTYPE html> 
<html> 
    <head> 
    <title></title> 
    <meta charset="UTF-8"> 
    <link rel="stylesheet" type="text/css" href="css/stylesheet.css"/> 
    <script type="text/javascript" src="javascript/javascript.js"></script> 
    </head> 
    <body> 
    <h1> 
     <img src="#" alt=""/> 
    </h1> 

    <h3>1. Getting Store categories</h3> 
    <button onclick="getCategories()">Click here to Get Categories.</button> 
    <p></p> 

    </body> 
</html> 

javascript.js:

function getcategories() 
{ 
    alert("TEST"); 
} 

EDDIT:stylesheet.css中:

* { 
    font-family: Ariel, Verdana, sans-serif; 
} 

h1 { 
    text-align: center; 
    color: #fff; 
    text-shadow: 0px 1px 0px #999, 0px 2px 0px #888, 0px 3px 0px #777, 0px 4px 0px #666, 0px 5px 0px #555, 0px 6px 0px #444, 0px 7px 0px #333, 0px 8px 7px #001135; 
    font: 80px 'ChunkFiveRegular'; 
} 

img { 
    position: absolute; 
    top: 0; bottom:0; left: 0; right:0; 
    margin: auto; 
} 

body { 
    background-color: #cccccc; 
} 
+2

'getCategories!= getcategories' – tymeJV

+3

您在HTML代码中将其称为'getCategories()',但在JavaScript代码中将'getcategories()'称为它。 – Pointy

+0

修复案件似乎没有工作。 –

回答

6

在你的HTML你写

getCategories 

但在你的JS你写

getcategories 

确保这些比赛。将来,打开您的开发工具(按F12)并查看控制台。它会告诉你一个错误,说你正在调用一个未定义的函数。

+0

就是这样。迈克C是对的。 –

1

JavaScript区分大小写。 getcategoriesgetCategories是不同的功能。改变两者的外壳是相同的,这将解决你的问题。

+0

怎么我错过了! –

+0

Stille nothing = [,改变案件无效。 –

相关问题