ids='+jsondata[0].id  你  的  s 也没用到

解决方案 »

  1.   

    回复于: 2014-07-29 11:38:42
    ids='+jsondata[0].id  你  的  s 也没用到这个用到了的,我传的就是第一个Id啊,我的s就写得是jsondata[0].id,但我想变成动态的jsondata[i].id 
      

  2.   

    回复于: 2014-07-29 11:43:02
    jsondata[i].id应该是这样吧如果我写成s=jsondata[i].id,  得到是最后学生的学号,注意我的each函数,我真不知道该怎么传了,直接换个方法吗
      

  3.   

       s=jsondata[0].id; 
    你这个 s  始终是 第一个啊。
      

  4.   

     s=jsondata[0].id; 
    你这个 s  始终是 第一个啊。我知道啊,我换了其他的也不行,我是先用第一个id做下面的功能的
      

  5.   

    s=jsondata[i].id; 
    那么你下面的s也要有同步下标位置的阿,这个s就是个数组了
    你试着这样  让你每个link后的参数值也是动态的阿
    "javascript:location.href='stumanager!queryInfo?ids='+s[i]"
      

  6.   


    我试过了啊,后面url的参数是跟不了数组的,这样的s【i】,它识别不了
      

  7.   

    onclick="javascript:location.href='stumanager!queryInfo?ids="+s[i]  
      

  8.   

    onclick="javascript:location.href='stumanager!queryInfo?ids=‘+s[i]+"
      

  9.   

    不知道你怎么写的。<!DOCTYPE html>
    <html>
        
        <head>
            <script src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js">
            </script>
            <script>
                $(document).ready(function() {
                    var json = [{
                        "id": "1",
                        "tagName": "apple1"
                    },
                    {
                        "id": "2",
                        "tagName": "apple2"
                    },
                    {
                        "id": "3",
                        "tagName": "apple3"
                    },
                    {
                        "id": "4",
                        "tagName": "apple4"
                    },
                    {
                        "id": "5",
                        "tagName": "apple5"
                    }];                $.each(json,
                    function(idx, obj) {                    $("#stu").append('<tr class="stuInfo" height="30"><td><span style="cursor:pointer" onclick="javascript:alert(' + obj.id + ');">查看学籍&nbsp;&nbsp;</span></td></tr>');
                    });            });
            </script>
        </head>
        
        <body>
            <table id="stu">
            </table>
        </body></html>
      

  10.   

    不知道是不是 你引号问题 ,$.each(json,
                    function(idx, obj) {                    $("#stu").append("<tr class='stuInfo' height='30'><td><span style='cursor:pointer' onclick='javascript:alert(" + obj.id + ");'>查看学籍&nbsp;&nbsp;</span></td></tr>");
                    });
      

  11.   


    不好意思,刚有事去了
    嗯,我弹的Id也是OK的,能麻烦你下把你弹的Id放到url地址栏里嘛,,我就这里出了问题
      

  12.   

    你看看吧。<!DOCTYPE html>
    <html>
        
        <head>
            <script src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js">
            </script>
            <script>
                $(document).ready(function() {
                    var json = [{
                        "id": "1",
                        "tagName": "apple1"
                    },
                    {
                        "id": "2",
                        "tagName": "apple2"
                    },
                    {
                        "id": "3",
                        "tagName": "apple3"
                    },
                    {
                        "id": "4",
                        "tagName": "apple4"
                    },
                    {
                        "id": "5",
                        "tagName": "apple5"
                    }];
                    var appendTr;
                    var param;
                    $.each(json,
                    function(idx, obj) {
                        param = "javascript:window.location.href='http://www.baidu.com/s?wd=" + obj.id + "'";
                        appendTr = "<tr class='stuInfo' height='30'><td><span style='cursor:pointer' onclick=" + param + ">查看学籍&nbsp;&nbsp;</span><span>删除</span></td></tr>";
                        $("#stu").append(appendTr);                });            });
            </script>
        </head>
        
        <body>
            <table id="stu">
            </table>
        </body></html>
      

  13.   

    我觉得你应该把这个onclick=“window.location.href=''”写成一个function,这样自己看的时候,也方便一点onclick="javascript:test(id)",没必要什么东西都堆一起