Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

jquery slideToggle question

Posted on 2014-02-28
1
246 Views
Last Modified: 2014-02-28
When someone clicks on the text "Click here to view phone number" the phone number appears below the text and it pushes content down. What I would like to do is the phone number should appear where the text is so the text will be hidden once the link was clicked (phone number replaces text).

				<div id="showphone">Click here to view phone number</div>
<div class="phone" style="display: none;"><span itemprop="telephone"><?php echo $attorneysStuff['bizPhone'];?></span></div>

<script>
   $(document).ready(function() {
        $('#showphone').click(function() {
                $('.phone').slideToggle("slow");
        });
    });

	</script>

Open in new window

0
Comment
Question by:seopti
1 Comment
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39896663
In that case I would suggest you change your html to this

<div id="showphone" data-tel="<?php echo $attorneysStuff['bizPhone'];?>">Click here to view phone number</div>

Open in new window


And your jquery would be
   $(document).ready(function() {
        $('#showphone').click(function() {
                $('#showphone').html($(this).data("tel"));
        });
    });

Open in new window


There is no point in the extraneous HTML if you are not using it.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
forgetful about js objects 8 46
Wordpress Security 29 48
Need help with jQuery elements filtering 2 12
Ajax and PHP 9 29
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 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