Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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 java脚本按钮未显示_Javascript_Html - Fatal编程技术网

Javascript java脚本按钮未显示

Javascript java脚本按钮未显示,javascript,html,Javascript,Html,好的,我从paul irish page获得了这段代码+一些修改,它为您提供了ie版本标准的东西: <!--[if lt IE 7 ]> <html class="ie6"> <![endif]--> <!--[if IE 7 ]> <html class="ie7"> <![endif]--> <!--[if IE 8 ]> <html class="ie8"> <![end

好的,我从paul irish page获得了这段代码+一些修改,它为您提供了ie版本标准的东西:

 <!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
 <!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
 <!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
 <!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
 <!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
<head>
</head>
<body>
<h1>test:</h1>
<script type="text/javascript"> 
$(function test()) {
"use strict";
// Detecting IE
var oldIE
if ($('html').is('.ie6, .ie7, .ie8')) {
    oldIE = true;
}
if (oldIE) == true {
document.write("version<ie9")

} else {
   document.write(" version => ie9")

}
}
</script>
<script type="text/javascript"> 
<button type="button" onclick="test()">testing</button>
</script>
</body>

 </html>
问题是它没有显示测试按钮,元素不应该被标签包围。毕竟,它是HTML,而不是JavaScript

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
<head>
<title>A HTML document needs a title to be valid.</title>
</head>
<body>
    <button id="test">I feel so clickable today.</button>

<!-- You must include jQuery before you can use its methods -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
"use strict";

    (function ($) {
        // Assignment with the ternary operator
        var oldIE = ($('html').is('.ie6, .ie7, .ie8')) ? true : false;

        // You need at least jQuery 1.7 to use .on()
        $('#test').on('click', function() {
            console.log(oldIE);
        });
    }(jQuery));

</script>
</body>
</html>
元素不应被标记包围。毕竟,它是HTML,而不是JavaScript

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
<head>
<title>A HTML document needs a title to be valid.</title>
</head>
<body>
    <button id="test">I feel so clickable today.</button>

<!-- You must include jQuery before you can use its methods -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
"use strict";

    (function ($) {
        // Assignment with the ternary operator
        var oldIE = ($('html').is('.ie6, .ie7, .ie8')) ? true : false;

        // You need at least jQuery 1.7 to use .on()
        $('#test').on('click', function() {
            console.log(oldIE);
        });
    }(jQuery));

</script>
</body>
</html>

但是,如果希望将其保留在脚本标记中,则需要修改代码,如下所示:

<script type="text/javascript"> 
   document.write('<button type="button" onclick="test()">testing</button>');
</script>

但是,如果希望将其保留在脚本标记中,则需要修改代码,如下所示:

<script type="text/javascript"> 
   document.write('<button type="button" onclick="test()">testing</button>');
</script>

我可能错了,但我很确定你不需要你的按钮在脚本标记之间。我可能错了,但我很确定你不需要你的按钮在脚本标记之间。太好了。我还添加了一些其他的东西,这可能会对你有所帮助:是的,泰,但我不明白为什么我没有得到一个结果老歌的价值正在被打印到控制台上。好了,我得到了这个错误:ie2.html,第16行6个字符的jQuery是未定义的,好吧,我知道了错误的原因,但我必须从其他代码中执行,因为当我们运行它时需要它,我们无法访问控制台,所以当您没有包含jQuery时,muchIt会说jQuery是未定义的。在脚本中使用jQuery库的任何方法之前,都应该包含jQuery库。此外,在开发过程中自由使用JavaScript控制台也是一个好习惯。Paul Irish创建了一个小脚本,可以在不提供控制台的浏览器中防止JS错误。我已经更新了我的答案。太好了。我还添加了一些其他的东西,这可能会对你有所帮助:是的,泰,但我不明白为什么我没有得到一个结果老歌的价值正在被打印到控制台上。好了,我得到了这个错误:ie2.html,第16行6个字符的jQuery是未定义的,好吧,我知道了错误的原因,但我必须从其他代码中执行,因为当我们运行它时需要它,我们无法访问控制台,所以当您没有包含jQuery时,muchIt会说jQuery是未定义的。在脚本中使用jQuery库的任何方法之前,都应该包含jQuery库。此外,在开发过程中自由使用JavaScript控制台也是一个好习惯。Paul Irish创建了一个小脚本,可以在不提供控制台的浏览器中防止JS错误。我已经更新了我的答案。