SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Help!! toggle

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help!! toggle

    Hi everyone,

    Im trying to get this hide, show, gife image to work on multiple pages but it seems to be working only on the first page not on the other pages?

    here is my code:


    echo "<div id=\"headerDivImg\" class=\"displayTitle\">$title_txt<a id=\"imageDivLink\" href=\"javascript:toggleDiv('contentDivImg', 'imageDivLink');\"><img src=\"../img/minus-2.png\"></a> </div> ";
    echo "<div class='maintitles_jd' id='contentDivImg' style='display:block;' >"; //job description content

    <script type="text/javascript">
    function toggleDiv(showHideDiv, switchImgTag) {
    var ele = document.getElementById(showHideDiv);
    var imageEle = document.getElementById(switchImgTag);

    if(ele.style.display == "block") {
    ele.style.display = "none";
    imageEle.innerHTML = '<img src="../img/plus-2.png">';
    }
    else {
    ele.style.display = "block";
    imageEle.innerHTML = '<img src="../img/minus-2.png">';
    }

    }
    </script>

  2. #2
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,742
    Mentioned
    47 Post(s)
    Tagged
    3 Thread(s)
    Hi,

    Could you post a link to a page where the code works and a second link to a page where it doesn't.
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What im trying to do is - is it possible to have multiple ID toggle?

  4. #4
    Grüße aus'm Pott
    SitePoint Award Recipient Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    2,742
    Mentioned
    47 Post(s)
    Tagged
    3 Thread(s)
    Yes, that should be possible, but I still haven't really grasped what you are trying to do.
    How well do you know your JavaScript from your jQuery?
    Check out SitePoint's latest JavaScript challenge


    My blog

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •