Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Need to remove color of other div using onclick

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #150691
    sbhambad
    Participant

    Hi,

    here is my requirement.

    I need to change the background color of div.it is working fine. but I want to remove the color of other div when I click on particular div.

    basically I need to highlight only one div at a time

    here is my code : $(document).ready(function () {

    var learn=””; $(“.container .productheader a”).click(function() { var current = $(this).attr(“id”); learn = current + “_text”; $(“#” + learn).css(‘background-color’, ‘#efefef’); $(“#” + learn).css(‘padding-left’, ’10px’);

           });
    

    });

    #150704
    Chromawoods
    Participant

    Hmm.. that code is a bit tricky to read at the moment. :) I think I understand what you aim to do though. Could you post an example of how the HTML looks? I suspect that you are making the solution more complicated than it needs to be.

    #150710
    Paulie_D
    Member

    Definitely. it should be just a matter of adding and removing a class.

    #150768
    Paulie_D
    Member
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.