in Education by
I have a sample code:
  • Bank1
  • Bank2
  • USD
  • EURO
And jquery: $(document).ready(function(){ $('.box li').click(function(){ $('#banks li').removeClass('active1'); $('#buttons li').removeClass('active2'); $(this).addClass('active1'); $(this).addClass('active2'); }); }); OUPUT: Error when click on:
  • Bank1
  • Bank2
  • USD
  • EURO
How to using jquery exactly for add class for 2 id are (banks and buttons) with 2 class are (active1, active2) JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
AS I understand you need to be able to choise single option in each section. Use only one active class and change styles in css: html:
  • Bank1
  • Bank2
  • USD
  • EURO
js: $(document).ready(function(){ $('.box li').click(function() { $(this).siblings('li').removeClass('active'); $(this).addClass('active'); }); }); css: .box li { cursor:pointer; } #banks .active { color:red; } #buttons .active { color:blue; } Code: http://jsfiddle.net/jn3v4/2/

Related questions

0 votes
    I tested out the script below in jsfiddle and it works fine, can someone guide me how to fix it? ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    What I'm trying to achieve is a list of links with some separate divs. at the moment the fading ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    What I'm trying to achieve is a list of links with some separate divs. at the moment the fading ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    What I'm trying to achieve is a list of links with some separate divs. at the moment the fading ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I created an list. When you select each , there will be active classes each. Now, my goal is how ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I want to know in spine how to add and remove active class for div. In the firebug I saw ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I am trying to set text and value for both td tag and input tag at the same time. But after ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I am trying to set text and value for both td tag and input tag at the same time. But after ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    Hi i'm using this to set a title attribute on elements: $('.upgradeTables thead tr td:gt(1)'). ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I found found several question's answers similar to this, I tried some of them, but no luck. May ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I found found several question's answers similar to this, I tried some of them, but no luck. May ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I wanted to find a way to extract from the url the classes to be added to the body. I made some ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I wanted to find a way to extract from the url the classes to be added to the body. I made some ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
...