Skip to main content
Source Link
user544079
  • 16.7k
  • 42
  • 120
  • 173

React JS onClick event handler

I have

var TestApp = React.createClass({ getComponent: function(){ console.log(this.props); }, render: function(){ return( <div> <ul> <li onClick={this.getComponent}>Component 1</li> </ul> </div> ); } }); React.renderComponent(<TestApp />, document.body); 

I want to color the background of the clicked list element. How can I do this in React ?

Something like

$('li').on('click', function(){ $(this).css({'background-color': '#ccc'}); });