小弟用一个浮出层插件写了一个鼠标移动到会员头像上就弹出相关资料等信息,跟微博等一样,但是不知道怎么取值,如下:<script>
$("#trigger5").powerFloat({
    eventType: "hover",
    target: "/member?id=?",  //这里id怎么取到会员的uid呢?求指点
    targetMode: "ajax"
});
</script>页面输出的内容为:<ul><li><a  href="http://localhost/?author=2"><img id="trigger5" src="http://localhost/id=1"/></a></li><li><a  href="http://localhost/wp/?author=1"><img id="trigger5" src="http://localhost/id=2"/></a></li><li><a  href="http://localhost/?author=4"><img id="trigger5" src="http://localhost/id=3"/></a></li></ul>求大牛指点

解决方案 »

  1.   

    首先,你的代码中有个错误
    html中id应该是唯一的,此处<img id="trigger5" src="http://localhost/id=2"/></a>不可能所有的img的id都是trigger5,建议使用类代码
    修正后的代码
    1.在img中加一个rel属性用于记录用户的id<ul>
        <li><a href="http://localhost/?author=2"><img class="trigger5" src="http://localhost/id=1" rel="1"/></a></li>
        <li><a href="http://localhost/wp/?author=1"><img class="trigger5" src="http://localhost/id=3" rel="2"/></a></li>
        <li><a href="http://localhost/?author=4"><img  class="trigger5" src="http://localhost/id=3" rel="3"/></a></li>
    </ul>2. 修改javascript<script>
    $(".trigger5").powerFloat({
        eventType: "hover",
        target: "/member?id=?"+$("this").attr('rel'),  //这里取rel属性
        targetMode: "ajax"
    });
    </script>
      

  2.   

    感谢uuleaf前辈指点,我已经改成如下输出:u<ul>
        <li><a href="http://localhost/?author=2"><img class="trigger5" src="http://localhost/id=1" rel="1"/></a></li>
        <li><a href="http://localhost/?author=1"><img class="trigger5" src="http://localhost/id=3" rel="2"/></a></li>
        <li><a href="http://localhost/?author=4"><img  class="trigger5" src="http://localhost/id=3" rel="3"/></a></li>
    </ul>javascript已修改:
    <script>
    $(".trigger5").powerFloat({
        eventType: "hover",
        target: "/member?id=?"+$("this").attr('rel'),  //这里取rel属性
        targetMode: "ajax"
    });
    </script>但是这个uid仍然取不到值,用firebug看了一下,传递的url如下:http://localhost/member-?id=undefined求大牛指点,谢谢
      

  3.   

    你是使用了jquery还是其它的js框架?
      

  4.   

    是我的问题,下面代码修改为
    <script>
    $(".trigger5").powerFloat({
        eventType: "hover",
        target: "/member?id=?"+$(this).attr('rel'),  //这里取rel属性
        targetMode: "ajax"
    });
    </script>
    $(this).attr('rel')我多加了两个引号
      

  5.   

    前辈还是不行,使用了jquery,用了这个浮动层插件:
    http://www.zhangxinxu.com/wordpress/?p=1328谢谢大牛不厌其烦的指点
      

  6.   

    例子在这里:http://www.zhangxinxu.com/study/201012/jquery-power-float-demo.html里面的“加载外部HTML片段”,这个片段,谢谢