0

Hi to all my co developer,

I Have a bug using this function.

function clickHandler() {
      $('#show').toggle('fast');
      $('#hide').toggle('fast');
  }

$(document).ready(function(){
       $('#show').hide();
        $('#hide').on('click', clickHandler);
});
   <li id="hide" ><a  href="switch_lang.php?lang=2">Arabic </a></li>
                              
   <li id="show" style="display:none;"><a href="switch_lang.php?lang=1">English  </a></li>
   
   

Problem: When I click the Arabic button did not hide or toggle to English button.

Thank you in advance.

1
  • Jquery referance may be missing. Commented May 18, 2017 at 12:11

3 Answers 3

1

Running code with toggle.

function clickHandler() {
  $('#show').toggle('fast');
  $('#hide').toggle('fast');
}
$(document).ready(function() {
  $('#show').hide();
  $('#hide,#show').on('click', clickHandler);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li id="hide"><a href="#">Arabic </a></li> // chage href to your real page

<li id="show" style="display:none;"><a href="#">English  </a></li>

Sign up to request clarification or add additional context in comments.

1 Comment

Did not work sir, I have a problem when it toggle to English button.
0

use the below code

  function clickHandler() {
  $('#show').toggle('fast');
  $('#hide').toggle('fast');     
   }
   $(document).ready(function(){
   $('#show').hide();
   $('#hide').on('click', clickHandler);
   $('#show').on('click', clickHandler);

    });

link toggle fiddle

2 Comments

Did not work sir, there's an issue of toggle to englesh
I already fix the issue sir. There's a conflict to my java script. thanks a lot
0

Below is the code:

function clickHandler() {
      $('#show').toggle('fast');
      $('#hide').toggle('fast');
      return false;
  }

$(document).ready(function(){
       $('#show').hide();
        $('#hide, #show').on('click', clickHandler);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li id="hide" ><a  href="switch_lang.php?lang=2">Arabic </a></li>
                              
   <li id="show" style="display:none;"><a href="switch_lang.php?lang=1">English  </a></li>

return false; was missing.

5 Comments

but there's no effect to my target link "href="switch_lang.php?lang=2"
how to fix that bug sir? that toggle to english and the target link is working.
What do you want to do with that target link?
when I click the arabic it toggle to english work fine but the target link did not take effect.
Still doesn't answer, what do you want to with that target link? Do you want to open than page when you click on the link? Do you want to change it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.