Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6832105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:49:06+00:00 2026-05-26T22:49:06+00:00

The problem On my page, when a specified <a> is clicked upon, another part

  • 0

The problem

On my page, when a specified <a> is clicked upon, another part of the page is supposed to change. In my case right now I’m trying to fade an image out (in order to show the image behind the first one), but I’ve tried it with different changes (changing z-index (with .css) or the src (using .attr)).

I’m sure the event is not the problem, it’s the trigger. I even got it to work with the following:

<a onclick='$("img").toggleClass("active")' class="wr-nav-prev"> 

But since I’m really new to javascript (and jQuery) I don’t want to settle for this way.

Trying to do the same this way:

$(".wr-nav-next").click(function(){
    $("img").toggleClass("active");
});

won’t work and I cannot find the reason. I changed the selector about a hundred times (the <a> wraps around a span and a div).

I hope you already see the problem and will inform me about my mistake when you are done laughing! 🙂

If not, maybe those parts of my code will help:
In the case that you need to see what it looks like: I was trying to rebuild this page / example called “Circle Navigation Effect with CSS3” by Mary Lou from Codrops

The HTML

A few lines (like the css links) missing. I’m pretty sure they are not important.

<script type="text/javascript" src="jquery-1.7.min.js"></script>
<script type="text/javascript" src="centeritem.js"></script>

<script type="text/javascript">
$(document).ready(function() {
    CenterItem('#wr');
});
$(window).resize(function() {
    CenterItem('#wr');
});
$(".wr-nav-next").click(function(){
    $("img").toggleClass("active");
});
</script>

</head>
<body>
<div id="wr">
    <div class="wr-nav"> 
        <a onclick='$("img").toggleClass("active")' class="wr-nav-prev"> 
            <span>Previous picture</span>
            <div></div>
        </a>
        <a class="wr-nav-next">
            <span>Next picture</span>
            <div></div>
        </a>
    </div>
    <div>
        <img class="active" src="Images/large/1.jpg">
        <img src="Images/large/2.jpg">
    </div>
</div>
</body>
</html>

The CSS

The css is a bit messy since I’ve been testing stuff with this stylesheet all day and I might have overlooked something while cleaning up.

#wr{
    position: relative;
    width: 820px;
    height: 600px;
    border: 0px solid rgba(153,153,153,1);
    background-color:rgba(0,102,204,0.4);
    -moz-border-radius: 50px;
    -webkit-border-radius: 50px;
    border-radius: 50px;
}

.wr-nav{
    position:relative;
    width: 770px;
    height: 120px;
    top: 25px;
    left: 25px;
}

.wr-nav a{
    position:absolute;
    height: 70px;
    width: 70px;
    top: 0px;
}

a.wr-nav-prev{
    left: 0px;
}

a.wr-nav-next{
    right: 0px;
}

.wr-nav a span{
    position: absolute;
    cursor: pointer;
    opacity: 0.9;
    display:block;
    width: 46px;
    height: 46px;
    top: 50%;
    left: 50%;
    margin: -23px 0 0 -23px;
    background-size: 17px 25px;
    text-indent: -9000px;
    -moz-border-radius: 23px;
    -webkit-border-radius: 23px;
    border-radius: 23px;
    -webkit-transition: all 0.4s ease;
    -moz-transition: all 0.4s ease;
    -o-transition: all 0.4s ease;
    -ms-transition: all 0.4s ease;
    transition: all 0.4s ease;
    background-color:rgba(204,204,204,1);
    background-repeat:no-repeat;
    background-position: center center;
}

.wr-nav a.wr-nav-prev span{
    background-image:url(Images/prev.png);
}

.wr-nav a.wr-nav-next span{
    background-image:url(Images/next.png);
}

.wr-nav a div{
    position: absolute;
    cursor: pointer;
    opacity:1;
    width: 0px;
    height: 0px;
    top: 50%;
    left: 50%;
    margin: 0px;
    -moz-border-radius: 0px;
    -webkit-border-radius: 0px;
    border-radius: 0px;
    -webkit-transition: all 0.2s ease-out;
    -moz-transition: all 0.2s ease-out;
    -o-transition: all 0.2s ease-out;
    -ms-transition: all 0.2s ease-out;
    transition: all 0.2s ease-out;
    background-repeat:no-repeat;
    background--position: center center;
}

.wr-nav a:hover span{
    width: 100px;
    height: 100px;
    -moz-border-radius: 50px;
    -webkit-border-radius: 50px;
    border-radius: 50px;
    margin: -50px 0 0 -50px;
    background-size: 22px 32px;
    background-color:rgba(0,102,204,1);
}

.wr-nav a:hover div{
    width: 90px;
    height: 90px;
    background-size: 100% 100%;
    margin: -45px 0 0 -45px;
    -moz-border-radius: 45px;
    -webkit-border-radius: 45px;
    border-radius: 45px;
}

.wr-nav a.wr-nav-prev div{
    background: rgba(255,153,51,1) url(Images/thumbs/1.jpg) no-repeat center center;
}

.wr-nav a.wr-nav-next div{
    background: rgba(153,153,153,1) url(Images/thumbs/2.jpg) no-repeat center center;
}

img{
    position: absolute;
    opacity: 0;
    border-top: 3px solid rgba(153,153,153,0.8);
    border-bottom: 3px solid rgba(153,153,153,0.8);
    -webkit-transition: all 0.2s ease-out;
    -moz-transition: all 0.2s ease-out;
    -o-transition: all 0.2s ease-out;
    -ms-transition: all 0.2s ease-out;
    transition: all 0.2s ease-out;
}

img.active{
    opacity: 1;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:49:07+00:00Added an answer on May 26, 2026 at 10:49 pm

    This should be inside your document ready function. Otherwise it tries to initialize the click on all elements before your code, which are none.

    $(function(){
        $(".wr-nav-next").click(function(){
            $("img").toggleClass("active");
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with a page where I am trying to get colorbox
Trying to use JSTL but have the following problem: Index.xhtml page: <?xml version=1.0 encoding=UTF-8?>
I've got a problem with my page's layout. I want to create 3 table
Problem: to show that a Not-SO-page has been discussed in SO when you at
The problem exists in my editme.aspx page. Error 1 The type 'editme' already contains
My page is not rendering properly in ie6 because of transparency problem in ie
Basically my problem is with the page at http://wiki.diablocommunity.com/index.php?title=Tristram_Cathedral Please see the screen shots
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I have an interesting problem when using partial page update in asp.net with scriptmanager
I have a problem logging onto a page and then using it with cURL.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.