-1

i have created a simple generator for my personal uses and everything's going well except my checkbox, I want it when i fill up everything and press generate also if the checkbox is checked it puts a tag to front and last example:

I couldn't find any solution for my issue since i couldn't explain it well so here i'm asking you guys

This is my demo:

<http://jsfiddle.net/z4yuqk5e/>

I want it like: when i press "Generate" and if "Bold" is checked, i want it to generate the text with bold tag

Daryan
  • 195
  • 1
  • 2
  • 11

1 Answers1

1

You just have to add simple condition: if bold is checked then wrap generated text with tag b. You can do it like this:

var toInsert = "<font color='" + $('#color').val() + " '>" + $('#choose_title').val() + "</font>";

if ($('#bold').is(':checked'))
    toInsert = "<b>" + toInsert + "</b>"

$('textarea').val(toInsert);

Full fiddle here: http://jsfiddle.net/mozkomor05/3c61k8fq/

WARNING: Font tag is deprecated. Use span instead! (See here)

mozkomor05
  • 1,367
  • 11
  • 21
  • I appreciate it, i know that but this generator is use for some game and span is not supported so i use Font tag – Daryan Dec 21 '18 at 20:25