I have some jquery which reveals and hides new div’s based on which button is pressed. Rather than buttons i would like to insert my own text/image and have them work in the same way, revealing and hiding the new windows.
Here is the jquery:
<script>
$(document).ready(function(){
$(".buttons").click(function () {
var divname= this.value;
$("#"+divname).show("slow").siblings().hide("slow");
});
});
</script>
Here is the code for one of the buttons which i would like changed to a a href tag.
<input type="button" id="button1" class="buttons" value="div1"></input>
Any help will be greatly appreciated. Thanks. Pia
You can use the jQuery
data()method – http://api.jquery.com/data/ – to store arbitrary data on the anchor element (the div ID) and then use that value to show the proper div:If you want to show two div’s using a class name instead of an ID, store the class name on the achor tag, set the same class on each of the divs you want to show, and reference it in jQuery using a
.instead of a#