Make button disappear

1

I have a code that when you click the disable button, asks the reason that you are turning off the photo. When you confirm this reason, it should disappear the button on the side. I have a code with javascript to do the whole part of asking the reason for disabling the photo, but I have no idea how to make the next button disappear.

This is the code in javascript:

$(document).on('click','.desativar', function(){
  var t = $(this);
  $.SmartMessageBox({
    title : "<?= $this->lang->line("con_inflaud_jus_msg_title"); ?>",
    content : "<?= $this->lang->line("con_inflaud_jus_msg_d"); ?>",
    buttons : "[<?= $this->lang->line("con_inflaud_jus_msg_btn_n"); ?>][<?= $this->lang->line("con_inflaud_jus_msg_btn_y"); ?>]",
    input : "text",
    inputValue: "",
    placeholder : "<?= $this->lang->line("con_inflaud_jus_msg_place"); ?>"
  }, function(ButtonPress, Value) {
    if(ButtonPress == "<?= $this->lang->line("con_inflaud_jus_msg_btn_n"); ?>"){
      return 0;
    }else{
      if(Value == ""){
        notifica('<?= $this->lang->line("con_inflaud_msg_erro_title"); ?>', '<?= $this->lang->line("con_inflaud_jus_msg_inpmpt"); ?>', 4000);
      }else{
        $.ajax({
          type: "POST",
          url: "Controller/Funcao/" + $(t).attr('id') + "/0",
          data: {justificativa: Value},
          dataType: "json",
          success: function(r) {
            if(r) {
              $(t).parent().parent().next().find('.msg_des').show();

              $(t).parent().parent().next().find('.graf_lau').css('display','none');
              $(t).parent().parent().next().find('blockquote > .graf_lau').css('display','block');
              $(t).parent().parent().next().find('.img_lau_d').show();
              $(t).parent().parent().next().find('.img_lau_a').css('display','none');
              $(t).removeClass('desabilitar btn-danger');
              $(t).addClass('habilitar btn-success');
              $(t).empty();
              $(t).append('<span class="btn-label"><i class="glyphicon glyphicon-ok"></i></span><?= $this->lang->line("view_inflaud_iten_btn_h"); ?>');
            } else {
              notifica('<?= $this->lang->line("con_inflaud_msg_erro_title"); ?>', '<?= $this->lang->line("con_inflaud_msg_erro_d"); ?>', 4000);
            }
          }
        });
      }
    }
  });
});
    
asked by anonymous 02.09.2015 / 13:10

2 answers

1

It can be done in a simple way, using the jQuery $ selector.

To hide the element:

$("#seuBotao").hide();

To display the element:

$("#seuBotao").show();
    
02.09.2015 / 13:54
1

You can also do this using AngularJS, using ng-if or ng-show .

Simple example:

<div ng-if="var == true">Isso vai aparecer quando a variavel "var" for verdadeira</div>

To use ng-show, just replace ng-if with ng-show . The difference is that the show just hides / shows, and if loads the element again.

    
16.08.2016 / 03:38