Using jQuery to test if an input has focus

后端 未结 15 1507
梦谈多话
梦谈多话 2020-11-22 05:42

On the front page of a site I am building, several

s use the CSS :hover pseudo-class to add a border when the mouse is over them. One of
15条回答
  •  隐瞒了意图╮
    2020-11-22 06:19

    An alternative to using classes to mark the state of an element is the internal data store functionality.

    P.S.: You are able to store booleans and whatever you desire using the data() function. It's not just about strings :)

    $("...").mouseover(function ()
    {
        // store state on element
    }).mouseout(function ()
    {
        // remove stored state on element
    });
    

    And then it's just a matter of accessing the state of elements.

提交回复
热议问题