+2  A: 

I think you intend to change the text of the P element as opposed to its name.

<p class="toggleIt">Hide</p> //want this to change to 'Show' after clicking
$('.toggleIt').click(function(){
  $('#common_fields').toggle();
  var thisElem = $(this);
  thisElem.text(thisElem.text() === "Show" ? "Hide" : "Show");
});
David Andres
Thank you.. This looked a lot simpler than the other answers,so went for this one.. Thanks to everyone..
Angeline Aarthi
A: 
$(".toggleIt").text("Show");

Make sure that that's the only <p> tag with the "toggleIt" class or you'll need to use a different selector.

womp
A: 

According to the code you posted above, you're not trying to change the name attribute, you're trying to change the text value/innerHTML of the element.

That's done by calling:

$('.toggleIt').click(function(){
     $('#common_fields').toggle().text('Show');
});

If you actually wanted to change the name attribute of the p element, you'd do:

$('.toggleIt').click(function(){
     $('#common_fields').toggle().attr('name', 'Show');
});
Gabriel Hurley
A: 
var toggleString = {
    show:'Show',
    hide:'Hide'
};

$('.toggleIt').toggle(function() {
    $('#common_fields').hide();
    $(this).text( toggleString.show );
}), function() {
    $('#common_fields').show();
    $(this).text( toggleString.hide );
});
meder
My method should work fine if it starts out as 'Hide' initially - otherwise just swap the function bodies of the two function literals I have.
meder
+1  A: 

You need to know if the #common_fields element is visible or not, in order to get the right 'Show' or 'Hide' text value:

$('.toggleIt').click(function(){
  var $commonFields = $('#common_fields');
      text = $commonFields.is(':visible') ? 'Show' : 'Hide';

  $(this).text(text);
  $commonFields.toggle();
});

Try the above snippet here.

CMS