-2

I'm trying to get this basic jquery function to work so I can use the same idea on a bigger part of a site I'm working on right now. Been looking through the code for an hour right now and I checked the jquery documentation to make sure I got the selectors all in the right place, and I've used the right selectors.

I just don't know how to fix it so when I click the button, the panel's font color changes.

https://jsfiddle.net/p28jjo2u/

    <div class="col-xs-3">
  <div id="panel4" class="panel panel-primary">
    <div class="panel-heading panel4">
      #panel4
    </div>
  </div>
</div>


<a class="btn btn-default" id="button" href="#" role="button">Link</a>

css

#button {
  outline: none;
}
#panel4 .panel4 {
  color: white;
}

jquery

//playing around with panels and buttons in schedule tab
$(document).ready(function(){
  $('#button').on('click', function() {
    $('#panel4').find('.panel4').css({
      'color': 'red';
    });
  });
});
arcyqwerty
  • 10,325
  • 4
  • 47
  • 84
Kyle Truong
  • 2,545
  • 8
  • 34
  • 50

2 Answers2

4

The console is your friend. You have a syntax error in

//playing around with panels and buttons in schedule tab
$(document).ready(function(){
  $('#button').on('click', function() {
    $('#panel4').find('.panel4').css({
      'color': 'red';
    });
  });
});

Remove the semicolon from 'color': 'red'; and it should work.

Jesse
  • 1,262
  • 1
  • 9
  • 19
3

See the console.

You have an extra ; in your css object.

https://jsfiddle.net/p28jjo2u/1/

//playing around with panels and buttons in schedule tab
$(document).ready(function(){
  $('#button').on('click', function() {
    $('#panel4').find('.panel4').css({
      'color': 'red'
    });
  });
});
arcyqwerty
  • 10,325
  • 4
  • 47
  • 84