Link to home
Start Free TrialLog in
Avatar of Wayne Barron
Wayne BarronFlag for United States of America

asked on

Get Toggle show/hide to work with Text, instead of images

Chris assisted with this code on the previous thread (Code below).
https://www.experts-exchange.com/questions/28015231/Show-Hide-JQuery-Script-Provided-working-Example-Add-Image-instead-of-Text.html?anchorAnswerId=38839928#a38839928

This code works with images, however, I also need to make it work with Text.
As I love how this works, and I am wanting to convert all my show/hide functions to this.

Thanks all;
Carrzkiss
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){  
	$('.ahref').click(function() {
		$(this).toggleClass('hidden'); //change the status of the link
		$($(this).data('div')).slideToggle(500); //toggle the visibility
	});
});
</script>

<style type="text/css">
	.ahref { background: url(http://cdn1.iconfinder.com/data/icons/diagona/icon/16/130.png) no-repeat left top; width: 16px; height: 16px; display:inline-block; cursor:pointer; }
	.hidden { background: url(http://cdn1.iconfinder.com/data/icons/diagona/icon/16/129.png) no-repeat left top; } 
</style>

<a class="ahref" data-div=".box1"></a>
<a class="ahref" data-div=".box2"></a>
<a class="ahref" data-div=".box3"></a>

<div class="box1">1</div> 
<div class="box2">2</div> 
<div class="box3">3</div>

Open in new window

Avatar of Deja Anbu
Deja Anbu
Flag of Oman image

now, what is the pbm with your attached code? can u elaborate?
Avatar of Wayne Barron

ASKER

as stated in the description.
This is with images, I need it to show text instead.

Show
Hide

Instead of the "Images"

This script was updated from the old text show/hide version.
As the older version would not work with the new jquery framework.
So, I am lost as to the way it needs to be coded, in order to hold the text.

You can chose text links, they just will not change once they are clicked on.

Carrzkiss
SOLUTION
Avatar of mcnute
mcnute
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mokatell
mokatell

Try This :       

-----> Style

#menuItems
{
width:960px;
display:none;
}

------> Html Tags

                 <ul ><li id="link"><span style="cursor:default"  >Hello</span></li></ul>

                $("#link").mousedown(function() {
                $("#menuItems").slideToggle(200);
                  });
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks guys.
I accepted both working examples, however, I will be going with Chris's code, as it is the most simplified of the 2.

Thanks a bunch guys.

Take Care
Carrzkiss