Focusing div elements with React

后端 未结 6 1738
不思量自难忘°
不思量自难忘° 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:46

    This worked in my case

    render: function(){
    
      if(this.props.edit){
        setTimeout(()=>{ this.divElement.focus() },0)
      }
    
        return 
    this.divElement = divElement} contentEditable={props.edit}/> }

提交回复
热议问题