按钮不't触发相应的动作(标记按钮和输入类型=按钮)

Button doesn't trigger the corresponding action (both tag button and input type=button)

本文关键字:按钮 类型 输入      更新时间:2023-09-26

我的jquery代码适用于Chrome、Firefox、>IE8,但jquery和jquery ui似乎没有加载在IE8上。

Javascript已启用。

我使用<meta http-equiv="X-UA-Compatible" content="IE=7,IE=8" />,因为我在IE9 上遇到了一些问题

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=8" />
<link href="css/my.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<link href="css/jquery-ui-timepicker-addon.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
         $(function(){
         }); // Sorry, really it's so and not only }
</script>
</head>

有什么建议吗?我应该检查什么?

编辑

通过更改

<meta http-equiv="X-UA-Compatible" content="IE=7,IE=8" />

<meta http-equiv="X-UA-Compatible" content="IE=8" />

解决了IE8上的大部分问题。

唯一仍然存在的问题是与弹出窗口有关:

当有一个按钮触发弹出窗口时,点击弹出窗口"OK"不会触发相应的操作(按钮在标签内)。

你试过这个吗?

<meta http-equiv="X-UA-Compatible" content="IE=8,IE=EDGE" />

你能把它放在jQuery.Ready函数中,看看它是否能在浏览器之间更一致地工作吗?我看到评论建议使用不同的格式:

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=8" />
<link href="css/my.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon.js"></script>
<link href="css/jquery-ui-timepicker-addon.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
         $(document).ready(function(){
            // do something here...
         }); // Sorry, really it's so and not only }
</script>
</head>

还建议将jquery、jquery ui、jquery ui-css和jquery验证更新到最新版本。您应该能够使用modernizr javascript库来检测您拥有的浏览器版本,然后应用这些元标记来满足您的需求。

此链接将检测您使用modernizr的浏览器版本。