Solved

jquery slideToggle question

Posted on 2014-02-28
1
247 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
[X]
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
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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

756 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