How can I find current element on mouseover using jQuery?

前端 未结 8 1724
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 07:10

How can I get the class name of the current element that is on mouseover? For example \"enter<

8条回答
  •  Happy的楠姐
    2020-12-24 07:49

    this should work:

    define a class in your style sheet:

    .detectable-div{
        border: white solid 1px;
    }
    
    .detectable-div:hover{
        border: red solid 1px;
    }
    

    then in your js:

    $('div.detectable-div:hover').mouseover(function () {
        $(this) // this is your object
    })
    

提交回复
热议问题