请问我的代码有什么问题,为什么执行不了?谢谢!

来源:1-11 编程练习

木讷25

2017-07-26 22:36

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="http://libs.baidu.com/jquery/1.8.2/jquery.js" type="text/javascript"></script>
        <title>挑战题</title>
    </head>
    <body>
        <input type="button" value="show infor" id="button"/>
        <ul id="infor"></ul>
        
        <script type="text/javascript">
            var myJson=[{"name":"zhang3","age":"27"},{"name":"li4", "age":"30"}];
            $("#button").click(function(){
                $.each(myJson,function(index,value){
                        $("#infor").append("<li>name: "+ value.name +" age: "+ value.age +"</li>");
                    })
                }
            )
        </script>
    </body>
</html>


写回答 关注

1回答

  • Bozens
    2017-07-27 11:21:10
    已采纳

    老哥看看你myJson之间的那个逗号是对的吗 应该是英文的,    

    细节要注意

    木讷25

    兄弟,谢谢指教!

    2017-07-27 16:57:36

    共 1 条回复 >

jQuery基础(五)一Ajax应用与常用插件

如何用jquery实现ajax应用,加入学习,有效提高前端开发速度

69094 学习 · 400 问题

查看课程

相似问题