Try this: jsfiddle
CSS:
.press
{
background-color:green;
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}
#input_text
{
background-color:black;
color:white;
font-weight:bold;
width:300px;
height:100px;
}
HTML:
<input type='button' id='but_a' class='normal' value='button A' />
<input type='button' id='but_b' class='normal' value='button B' />
<br />
<br />
<div id='input_text'></div>
Jquery:
$('#input_text').hide()
var textim = new Array();
textim['but_a'] = 'button A text is now displayed';
textim['but_b'] = 'button B text is now displayed';
$('.normal').click(function() {
if($(this).hasClass('press'))
{
$(this).removeClass('press');
$('#input_text').slideUp('slow', function(){ $('#input_text').empty(); });
}
else
{
$('.normal').removeClass('press');
$(this).addClass('press');
var idd = $(this).attr('id');
$('#input_text').empty();
$('#input_text').slideDown('slow', function() { $('#input_text').text(textim[idd]); } );
}
});
Have fun...
Edit:
note that - the array (textim) key's should be set to the same id of the button you want to trigger.