How do you change the colors of blocks div to js?



  • There's a block where the colors are different. (Panel leaves on the right side) when the click on the block changes the color of the panel from the top.

    How do we make it possible to change the colour separately for the upper and separate side block, followed by the local Storage?

    All code for: https://jsfiddle.net/cLc36xwr/

    Js:

      var $box_menu = $('.box_menu');
    //var $box_left = $('.box_left');
    

    $('.metro li').each(function(){
    var color = $(this).css('backgroundColor');
    $(this).click(function() {
    $box_menu.css('backgroundColor', color);
    });
    });



  • Like you can do. select There's gonna be a choice that we're changing color for now. And when you're on the colour, you're gonna put a color on your constituents. ♪ value Ooh. options We can, like, keep a class or something. id an element that changes color. Example of decision https://jsfiddle.net/cLc36xwr/3/

    var $currentPanel = $('#currentElement');
    

    $('.metro li').on('click', function (event){
    var $panel = $($currentPanel.val());
    //Не очень хорошо хранить значение прямо в span, лучше использовать data-color аттрибут или как-то еще хранить.
    $panel.css({
    backgroundColor: $(event.currentTarget).find('span').html()
    });
    });




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2