CodeIgniter Forums
Javascript - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Javascript (/showthread.php?tid=48704)



Javascript - El Forum - 01-25-2012

[eluser]ibnclaudius[/eluser]
I have this code:

Code:
$("#buttom-show-register-99").click(function () {
  $("#div-register-99").fadeIn(500);
  $('#buttom-show-register-99').attr('id', 'buttom-hide-register-99');
});

The div fadein, but the id of the button don't change. Why? Confused


Javascript - El Forum - 01-25-2012

[eluser]Aken[/eluser]
You should leave the ID as-is and add/remove a class to specify if it should be hidden or not. You can also just hide it immediately with jQuery.
Code:
$('#button-show-register-99').click(function() {
$('#div-register-99').fadeIn(500);
$(this).hide();
});