-, :
$(".Hide").hide();
, DIV, . :
var id = $(this).attr("id").replace("btn_", "");
HTML .
However, I would recommend using the attribute data-*to store the identifier. A complete solution would look like this:
<a href="#" id="btn_one" data-showid="one" class="btn">one</a>
<a href="#" id="btn_two" data-showid="two" class="btn">two</a>
<a href="#" id="btn_three" data-showid="three" class="btn">three</a>
<div id="one" class="Hide">1</div>
<div id="two" class="Hide">2</div>
<div id="three" class="Hide">3</div>
with the following javascript / jQuery:
$(".btn").click(function(e){
e.preventDefault();
$(".Hide").hide();
var id = $(this).data("showid");
$("#" + id).show();
});
Here is a working example
source
share