my javascript code should show 1 div and hide others according to where i click. it is working perfectly on desktop.
- $(document).ready(function(){
- $("#canada-map").click(function(){
- $("#centrik").show();
- $("#axance").hide();
- });
- });
I am making my website responsive, so I added a condition that checks window width:
- $(document).ready(function(){
- $("#canada-map").click(function(){
- if($(window).width()>480)
- {
- $("#centrik").show();
- $("#axance").hide();
- }
- else
- {
- $("#centrik").show();
- $("#axance").hide();
- $('#contact-mobile').stop().animate({ height: 610, opacity: 1 }, 'slow'); }
- });
- });
When I added the condition, everything worked except the show
and hide
in the else
. show
and hide
worked in the if
, and the animation of #contact-mobile
worked in else
.
What can the problem be? thanks