js ctrlKey怎么使用?
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
// 能不能不用 $("botton").click(function (){...} );这种方式?

function hello(e){
if(e.ctrlKey){
alert("hello world");
}

</script>
<button onclick="hello(this);">hello</button><!-- 为什么ctrl+点击了没反应 -->

解决方案 »

  1.   

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
        // 能不能不用 $("botton").click(function (){...} );这种方式?
        
        function hello(e){
            e = event || window.event;//兼容浏览器
            if(e.ctrlKey){
                alert("hello world");
            }
        } 
    </script>
    <button onclick="hello(event);">hello</button>//这里是event,不是this;且event固定这么写<!-- 为什么ctrl+点击了没反应 -->
      

  2.   

    谢谢ibm哥哥,有空帮忙看看这个问题,问了n个论坛,没人会。
    如何让“节点树”和“节点”的“选中”同时对应执行?