[Solved] React jQuery(this) selector is not working


this points to React component instance and not the input element. You can achieve this using event.target

class LoginReg extends Component {
    render() {
        function minimizeLabel(event){
            $(event.target).closest(".Reg-fields").css("border-bottom", "2px solid #f99");
            $(event.target).closest("label").css("top", "-15px").css("font-size", ".7em").css("transition", ".3s ease-out");
        }

        return (
            <div>
              <div className="custom-container">
                <div className="Reg-fields">
                  <input type="email" onClick={minimizeLabel}/>
                  <label>Email</label>
                </div>
              </div>
         );
}

1

solved React jQuery(this) selector is not working