Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use jQuery $(this) in react js function [closed]

I am working on reactjs and on click I am calling a function.

In that function I want to use jQuery $this to change the text of that element. Is it possible to do so?

Or is there any way with reactjs to change the current elements text?

like image 499
Sameer Sheikh Avatar asked Oct 18 '22 22:10

Sameer Sheikh


1 Answers

If you need just change text for element that was clicked you can do it like this

var Component = React.createClass({
    handleClick(e) {
        e.currentTarget.innerHTML = 'New Text';
    },

    render() {
        return <div onClick={this.handleClick}>Change Text</div>;
    }
});

Example

and using jQuery in our case is not necessary

like image 53
Oleksandr T. Avatar answered Oct 21 '22 22:10

Oleksandr T.