jquery 怎样取得html,load后的对象?
我用$("#b").html(<a id="a">测试</a>)加载后
$("#a").click() 找不到这个对象
怎么办啊

解决方案 »

  1.   

    你是找不到对象还是找不到这个事件?你搞清楚了么?没有定义click这个事件?
      

  2.   

    这个没什么,你看我这里都可以正常运行http://dl.dropbox.com/u/2555620/jquery/test.html实在不行你可以这样写:
    setTimeout(function() {$("#a").click();},0);
      

  3.   

    没定义click也不会报错,
    找不到对象指$("#a")为空
      

  4.   

    哦 谢谢 呵呵 我也是刚学这个 jQuery
      

  5.   

    知道了,是js执行也有顺序的原因
    <script>$(document).ready(function() {
    $("#b").html( '<a id="a">测试 </a>');
    });$(document).ready(function() {
    $("#a").click(function() {
    alert("a");
    });
    });
    </script> 
    <div id="b">
    </div>
    这样能执行
    <script>
    $(document).ready(function() {
    $("#a").click(function() {
    alert("a");
    });
    });
    $(document).ready(function() {
    $("#b").html( '<a id="a">测试 </a>');
    });</script> 
    <div id="b">
    </div>这样就找不到了
      

  6.   

    谢谢各位了,特别是sohighthesky,