Make button disappear

Asked

Viewed 2,569 times

1

I have a code that when you click the deactivate button, asks you why you’re deactivating the photo. When you confirm that motive, he should disappear the button on the side. I have a code with javascript to do the whole part of asking the reason for the photo deactivation, but I have no idea how to make the next button disappear.

This is the javascript code:

$(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);
            }
          }
        });
      }
    }
  });
});
  • 1

    It can be done like this document.getElementById("myBtn").style.display="none";&#xA; just change myBtn for id of your button

  • 1

    detail, this .css('display','none'); and the same thing only that in jquery probably your selector is not being found.

  • @Gabrielrodrigues this code you sent me worked, thank you very much, but this button repeats, if I call him by id will only work for the first time.

  • As this button repeats, clicking disable will "disappear" all buttons or just one?

  • You can display the HTML of both buttons?

2 answers

1

It is also possible to do this using Angularjs, using the ng-if or the ng-show.

Simple example:

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

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

1

Can be done in a simple way by using jQuery’s $ selector.

To hide the element:

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

To show the widget:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.