Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

JS - click and not jump to top with preventDefault()

0 votes
17 views
added Mar 6 in Javascript by LC Marshal Captain (20,510 points)
retagged May 17 by LC Marshal
  handleToggle(e) {
    e.preventDefault();
    this.setState( {
      isExpanded: !this.state.isExpanded
    })
  }

 

2 Responses

0 votes
responded May 17 by LC Marshal Captain (20,510 points)
handleClick(e) {
  e.preventDefault();
  const { onClick } = this.props;
  onClick(e);
}

 

0 votes
responded May 17 by LC Marshal Captain (20,510 points)
dancingDodo = e => {
 e.preventDefault();
 // do dancingDodo here
}

render() {
    return(
        <a onClick={this.dancingDodo} href="/">Dododo</a>
    );
}

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...