Focusing div elements with React

后端 未结 6 1745
不思量自难忘°
不思量自难忘° 2020-12-15 06:16

Is it possible to focus div (or any other elements) using the focus() method?

I\'ve set a tabIndex to a div element:

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 06:28

    Not sure if this is the proper way, but I found that this worked for me.

    render() {
      return 
    this.refs.item.focus()}>I will have focus
    }

提交回复
热议问题