Untitled
raw download clone
TEXT
views 46
,
size 1406 b
$(document).ready(function(){
        x = 1
        console.log('aa')
        $("#btn").click(function(){
          console.log('couit')
          var c = $("#selection option:selected").val()
            switch (c) {
                case "0":
                  $("#text").append(' '+ $("#rtext").val());
                  break;
                case "1":
                  $("#text").prepend($("#rtext").val()+' ');
                  break;
                case "2":
                  var a = $("#rtext").val();
                  $( "#text" ).after( "<p>"+a+" <button type='button' id = rbtn"+x+" class = 'bton'>Remove</button></p>" );
                  x = x+1
                  break;
                case "3":
                  var b = $("#rtext").val();
                  $( "#text" ).before( "<p>"+b+" <button type='button' id = rbtn"+x+" class = 'bton'>Remove</button></p>" );
                  x = x+1;
                  break;
                case "4":
                    //console.log($("#rtext").val());
                    $("#rtext").appendTo("#text");
                  break;
                case "5":
                  $("#rtext").prependTo("#text");
              }
        //Remove butoon for remove 
        $(".bton").click(function(){
          var r = this.id
          var r= '#'+r
          $(r).parent("p").remove()
        });
      });

});
close fullscreen
Login or Register to edit or fork this paste. It's free.