-2

I have a simple submit button like this:

     <button
       type="submit"
       value="Create New Item"
       className="btn btn-lg btn-primary btn-block mt-4"
     />

and I've been wondering, why the value (label of the button) has the default value instead of desired one ("Create New Item"), no matter what I do. The same goes to input type="submit", but after reading this, I decided to stick with button.

Any ideas why I can't change the value?

Rob
  • 14,746
  • 28
  • 47
  • 65
pidabrow
  • 966
  • 1
  • 21
  • 47
  • Seriously, what exactly is the question and the title of the question doesn't make any sense. Why react js tagged in this? – Karthi Keyan Nov 25 '19 at 12:58
  • Your HTML is invalid. – Rob Nov 25 '19 at 13:05
  • @KarthiKeyan I used `className` instead of `class` in button declaration, which is a React thing. I thought that the fact, that I'm unable to change the label might be a similar case like `class` vs `className`. – pidabrow Nov 25 '19 at 13:24
  • @pidabrow what you see as default value for the label of the button? – tareq aziz Nov 25 '19 at 13:34

6 Answers6

1

Try this one,

<button onClick={onClickMethod}> Click Here </button>
XVallerie
  • 141
  • 2
  • 11
1

<input type="submit" value="Create New Item" className="btn btn-lg btn-primary btn-block mt-4" />

Change button, to input type="submit"

0

PLease delcare the button as below

<button type="submit" className="btn btn-lg btn-primary btn-block mt-4">
   Create New Item
</button>
tareq aziz
  • 749
  • 4
  • 11
Aneesh
  • 29
  • 5
0

if you want to change the text inside a button dynamically; you should set it like:

<button>{this.state.buttonLabel}</button>
Berk Elmas
  • 19
  • 1
  • 3
0

Just use the element like this

 <button type="submit" className="btn btn-lg btn-primary btn-block mt-4">Create 
 New Item</button/>
Martin
  • 22,212
  • 11
  • 70
  • 132
Antoan Elenkov
  • 711
  • 1
  • 5
  • 20
0

You no need to specify the input type, just replace with as below:

<button className="btn btn-lg btn-primary btn-block mt-4">
Create New Item
</button>

You can add onClick event.

Govind Soni
  • 320
  • 1
  • 2
  • 11