Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone

I am facing a problem whenever I click on link doesn't show on single click. I need to do double click on link then it display the

where an answer is written.

and as i again click(single click) on the same link it answer get disappear.

so why it doesn't show answer on single click of the link. I need to click twice on the link then it appear the following

  • .

    I am posting my code here..



    I am using the following .css
    CSS
    .head
    {
        font-size:16px;
        font-weight:bold;
        text-decoration:underline;
    }
    .quest
    {
        padding-left:15px;
        cursor:pointer;
    }
    .answer
    {
        padding-left:12px;
        display:none;
    }




    I am using the following code in .aspx

    XML
    <fieldset>
    <ul id="odUL">
                    <li id="Order"><span class="head">Order:</span>
                    <ul><br />
                        <li class="quest" onclick="showAnswer('od1')">
                            <u><span style="cursor:hand;">What does an order mean?</span></u>
                            <p id="od1" class="answer">
                                <b>Ans.</b> An order is a quantity of goods or items purchased.
                            </p>
                        </li>
                        <li class="quest">
                            <a href="javascript:showAnswer('od2')">
                                How can i check my current order status?
                            </a>
                            <p id="od2" class="answer">
                                <b>Ans.</b> You can check current order statur in MyOrders section.
                            </p>
                        </li>

    </ul>
    </fieldset>



    I am using the following javascript code

    C#
    function showAnswer(element)
        {
            if(document.getElementById(element).style.display=="none")
            {
                document.getElementById(element).style.display="block";
            }
            else
            {
                document.getElementById(element).style.display="none";
            }
        }
  • Posted
    Comments
    Christian Graus 2-Jul-11 2:52am    
    Have you tried debugging it ? Setting breakpoints, or using alerts to tell you if it's being clicked, and what is happening ?

    1 solution

    please try this for show:

    <pre>document.getElementById(element).style.display="";</pre>
     
    Share this answer
     

    This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



    CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900