Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从绑定到具有该元素id的元素的类调用函数?_Javascript_Html - Fatal编程技术网

Javascript 如何从绑定到具有该元素id的元素的类调用函数?

Javascript 如何从绑定到具有该元素id的元素的类调用函数?,javascript,html,Javascript,Html,这是我的密码: <html> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Kalendae/0.7.1/kalendae.css" type="text/css" charset="utf-8"> <script src="https://cdnjs.cloudflare.com/ajax/libs/Kalendae/0.7.1/kalendae.standalone.js"

这是我的密码:

<html>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Kalendae/0.7.1/kalendae.css" type="text/css" charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Kalendae/0.7.1/kalendae.standalone.js" type="text/javascript" charset="utf-8"></script>
<body>
<script type="text/javascript">
        function myFunction() {
            alert("toto");
        document.getElementById("testKal").draw(); // i want to activate the draw function of auto-kal
    }
</script>

<img src="https://www.dropbox.com/s/hz8nrhh0yosvpgy/calendar.png?dl=1" id="imgTest" onclick="myFunction()">&nbsp;<input type="text" class="auto-kal" id="testKal">
</body>
</html>

函数myFunction(){
警惕(“toto”);
document.getElementById(“testKal”).draw();//我想激活auto-kal的draw函数
}
我希望当我点击日历图片时,日历的输入文本弹出

这是kalendae的函数图

我还尝试在单击图像时激活testKal的click()函数:

<html>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Kalendae/0.7.1/kalendae.css" type="text/css" charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Kalendae/0.7.1/kalendae.standalone.js" type="text/javascript" charset="utf-8"></script>
<body>
<script type="text/javascript">
        function myFunction() {
            alert("toto");
        document.getElementById("testKal").click(); // i want to activate the draw function of auto-kal
    }
</script>

函数myFunction(){
警惕(“toto”);
document.getElementById(“testKal”)。单击();//我想激活auto kal的绘图功能
}
下面是一个使用draw函数的小提琴:

还有一个尝试通过点击:


您需要触发输入的焦点事件


您需要触发输入的焦点事件

document.getElementById("testKal").focus();
document.getElementById("testKal").focus();