Skip to main content
edited title
Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

Refactor code - displaying Displaying text on button click

editadded fiddle
Source Link

Displaying Refactor code - displaying text on button click

Here is a working fiddle.

Displaying text on button click

Refactor code - displaying text on button click

Here is a working fiddle.

deleted 259 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

jquery - refactor code to replace 6 functions Displaying text on button click

I have some JS code that when the user clicks the add"add" button, some text is displayed to a textarea.

The code seems to be working OK. However, I realize I must refactor the code so that I am using only the one on click function instead of the six that I have for each of the 6 add buttons.

I have made many attempts at this, searched google and read a lot of SO posts, but each attempt I have does not work.

Can someone give me some advice on this, I am going around in circles and not coming close to refactoring this code.

Here is my code:

jquery - refactor code to replace 6 functions

I have some JS code that when the user clicks the add button, some text is displayed to a textarea.

The code seems to be working OK. However, I realize I must refactor the code so that I am using only the one on click function instead of the six that I have for each of the 6 add buttons.

I have made many attempts at this, searched google and read a lot of SO posts, but each attempt I have does not work.

Can someone give me some advice on this, I am going around in circles and not coming close to refactoring this code.

Here is my code:

Displaying text on button click

I have some JS code that when the user clicks the "add" button, some text is displayed to a textarea.

The code seems to be working OK. However, I realize I must refactor the code so that I am using only the one on click function instead of the six that I have for each of the 6 add buttons.

changed title as suggested
Link
Loading
Post Migrated Here from stackoverflow.com (revisions)
Source Link
Loading