开发者

Call javascript on checkbox onclick

开发者 https://www.devze.com 2023-01-19 04:59 出处:网络
I don\'t understand what I\'m doing wrong here. I just want my function to be called when I click the checkbox. Replacing the function call with alert(开发者_运维百科) works, am I referencing my funct

I don't understand what I'm doing wrong here. I just want my function to be called when I click the checkbox. Replacing the function call with alert(开发者_运维百科) works, am I referencing my function incorrectly?

<html>
<head></head>
<body>

<script type="text/javascript">
function select(a){
    document.getElementById("myDiv").innerHTML=""+a;
}
</script>

<input type="checkbox" onclick="select(1)">

<div id="myDiv">hi</div>

</body>
</html>

Thanks


Change the function name [e.g. selectFun]. select seems to be reserved keyword


This puzzled me as it looked ok to me too, So ran through the usual tests, eventually tried changing the function name and that worked fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消