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 8455135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:12:26+00:00 2026-06-10T12:12:26+00:00

I have the following problem: in order to mark an element during different situation

  • 0

I have the following problem: in order to mark an element during different situation I want to add a class to the element:

jQuery('#menu-item-41 a').addClass('newsbox-closed1');

Later I want to do some funny staff when the element with this class is clicked – so far it works fine:

jQuery('.newsbox-closed1').click(function(){
      jQuery('#newsbox').css('display', 'block');
      jQuery(this).css('background-color', '#FF33AB').removeClass('newsbox-closed1').addClass('news-open');
 });

Until now everything is just fine. The element gets the class “news-open” andf the newsbox appears. But then the following does not work anymore:

jQuery('.news-open').click(function(){
  alert('JUCVJU');
  jQuery(this).removeClass('news-open').addClass('newsbox-closed2');
  jQuery('#newsbox').css('display', 'none');
});

Idea: when someone clicks on the same link again, the newsbox should disappear and the link gets a new class. This does not work – the class “new-open” is not removed, the alertbox is not shown, nothing.
Additionally the following work half the way – it is a close button on the newsbox:

jQuery('#close').click(function(){
  jQuery('#newsbox').css('display', 'none');
  jQuery('.news-open').removeClass('news-offen').addClass('newsbox-closed2')
});

The element with id “newsbox” disappears but the second part has no effect. The class remains of this element. I get no error messages, nothing… does anyone has an idea what can cause this?

Best,
Tobias

  • 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-06-10T12:12:27+00:00Added an answer on June 10, 2026 at 12:12 pm

    You are adding class at runtime. Change

    jQuery('.news-open').click(function(){
    

    to

    jQuery('.news-open').on('click',(function(){
    

    Above is for JQuery >=1.7

    For JQuery <1.7, use

    jQuery('.news-open').live('click',function(){
    

    live and on in JQuery work for elements created at runtime too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem I have the following mark-up: <div id=progress-bar> <div id=step-1 class=active><p>1. Select Room</p></div> <div
I am using GWT/JAVA for development. I have following problem: I want to remove
I have the following problem: I am creating a simple plugin jquery carousel, to
i have following problem: i have these files developer_identity.cer Team_Provisioning_Profile_.mobileprovision In order to package
I am facing the following problem: I have a HTML document where I want
I have following problem: My webservice application returns xml data in following order: <my_claims>
I have the following problem. I want to write my own slide show in
I still have following problem EXPLAIN EXTENDED SELECT `item`.`id`, `item`.`timestamp`, `item`.`label` FROM item WHERE
Suppose we have the following problem - we want to read a set of
I have following problem: I have to make a ASP.NET Webapplication with a two-row

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.