当前位置:编程学习 > C#/ASP.NET >>

jquery怎么获得选中对象

例:

$(document).ready(function(){
$("a").mouseover(function(){
//获得了a标签的对象集合。
//然后怎么获取我鼠标移上去那个控件的对象, });
});
--------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 比如textbox文本
$("#txt").attr("value") --------------------编程问答-------------------- 通过索引获取 $(document).ready(function(){
            $("a")[i].mouseover(function(){


里面的i就是该对象的索引号
--------------------编程问答--------------------
引用 4 楼 xiaofanxiok 的回复:
通过索引获取 $(document).ready(function(){
  $("a")[i].mouseover(function(){


里面的i就是该对象的索引号


那我移上去怎么获得我移上去的对象啊。你$("a")[i]这样是知道对象的位置。
而问题是我是要移上去   i    是多少 --------------------编程问答-------------------- <script type="text/javascript">
    $(function () {
        $("#divd").mouseover(function (e) { alert(e.currentTarget); })
    })
</script>


写了一个例子,你看看 .  e.currentTarget就是指触发事件对象本身。 --------------------编程问答--------------------


$(document).ready(function(){
    $("a").mouseover(function(){
        // 获得了a标签的对象集合。
        // 然后怎么获取我鼠标移上去那个控件的对象,                                        
        alert($(this).html());
    });
});


--------------------编程问答-------------------- --------------------编程问答--------------------
引用 6 楼 xiaofanxiok 的回复:
<script type="text/javascript">
  $(function () {
  $("#divd").mouseover(function (e) { alert(e.currentTarget); })
  })
</script>


写了一个例子,你看看 . e.currentTarget就是指触发事件对象本身。


我试试。 --------------------编程问答-------------------- 呵呵。可以的。谢谢啦。我怎么就不懂呢 --------------------编程问答-------------------- --------------------编程问答-------------------- 我也是刚学网站编程,不懂的地方大家一起学习 --------------------编程问答-------------------- e.currentTarget jquery手册上好像没嘛。。。。 --------------------编程问答-------------------- 这个是javascript原生的dd,jquery没有包装过肯定没有啦 --------------------编程问答--------------------
引用 14 楼 showenxxx 的回复:
这个是javascript原生的dd,jquery没有包装过肯定没有啦

哦。谢谢 --------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- 下载一个JQUERY的文档,看看选择器的内容。 --------------------编程问答--------------------

$(function(){
  $("a").mouseover(function(){
     this.  //用this.就是当前触发事件的这个对象的操作
  });
})
--------------------编程问答-------------------- IE中
srcElement; //获取当前点击事件的事件源对象
targetElement; //获取当前事件的事件目标对象
FF中
上述两个对象都是relatedTarget

      var e = event ? event : window.event;
      $(document).ready(function(){
            $("a").each(function(){
                  $(this).mouseover(function(){
                       var target = e.targetElement ? e.targetElement : e.relatedTarget;
                       if(target != null)
                           //操作
                     });
             });
        });

--------------------编程问答-------------------- 指定的对象 建议用获取id的方法获取
$("#demo") 选取 id="demo" 的
元素。 --------------------编程问答-------------------- 方法里用this就可以了
this就是指代触发事件的dom元素
$(this)就是jq对象
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,