Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding button using jQuery

Can someone please tell me how I can hide this button after pressing it using jQuery?

<input type="button" name="Comanda" value="Comanda" id="Comanda" data-clicked="unclicked" />

Or this one:

<input type=submit  name="Vizualizeaza" value="Vizualizeaza">
like image 580
LoolKovsky Avatar asked Oct 08 '12 22:10

LoolKovsky


People also ask

How do you hide a button after it is clicked in jQuery?

Syntax: $(selector). hide(speed,callback);

How do I hide a button?

You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid. A hidden <button> is not visible, but maintains its position on the page.

How we hide the elements in jQuery give an example?

jQuery | hide() with Examples The hide() is an inbuilt method in jQuery used to hide the selected element. Syntax: $(selector). hide(duration, easing, call_function);


2 Answers

Try this:

$('input[name=Comanda]')
.click(
     function ()
     {
         $(this).hide();
     }
);

For doing everything else you can use something like this one:

$('input[name=Comanda]')
.click(
     function ()
     {
         $(this).hide();

         $(".ClassNameOfShouldBeHiddenElements").hide();
     }
);

For hidding any other elements based on their IDs, use this one:

$('input[name=Comanda]')
.click(
     function ()
     {
         $(this).hide();

         $("#FirstElement").hide();
         $("#SecondElement").hide();
         $("#ThirdElement").hide();
     }
);
like image 194
Rikki Avatar answered Oct 03 '22 17:10

Rikki


You can use the .hide() function bound to a click handler:

$('#Comanda').click(function() {
    $(this).hide();
});
like image 43
Blender Avatar answered Oct 03 '22 18:10

Blender