Jquery graphic and text swap

Posted on 2010-09-01
Last Modified: 2012-05-10
Hi, I am building a page which uses Jquery slidetoggle to reveal a map when clicked. The text on the box initially says 'View the interactive map' and has an arrow pointing downwards.

What I want is when the map is visible (once clicked), the words to then change to 'Close the interactive map' and the arrow to change upwards.

My page is here -

Can anyone help?
<script type="text/javascript">
       $(function() {
            $("#toggle").click(function() {

Open in new window

Question by:matreece

Accepted Solution

hrgdavor earned 500 total points
ID: 33578103
add another div like
and replace the script with the script provided
<div id="toggle2" style="display:none"><img src="img/ArrowUp.png" width="9" height="6" /> Hide the Interactive Map</div>
<script type="text/javascript">
       $(function() {
            $("#toggle").click(function() {
            $("#toggle2").click(function() {

Open in new window

LVL 10

Expert Comment

by:Hans Langer
ID: 33579344
Try this:

<script type="text/javascript">
$(function() {
	$("#toggle").click(function() {
				var img = $("#toggle").find('img').attr('src','img/ArrowDown.png')
				$("#toggle").html(' Hide the Interactive Map').prepend(img)
				var img = $("#toggle").find('img').attr('src','img/ArrowUp.png')
				$("#toggle").html(' View the Interactive Map').prepend(img)

Open in new window


Author Closing Comment

ID: 33584417
This is great. Worked 1st time with no problems.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint 2013 List with Ratings 6 26
jQuery AJAX Redirects Without Response/Error 10 42
Error in JQuery 5 34
compact pure CSS Read More Toggle 4 18
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now