Problem with jQuery processing logic
Hey guys,
I've got a problem with using jQuery for changing class-attributes of some DOM-Objects.
I've gote some Code like this:
- $(document).ready(function () {
- $('#bundles').click( function () {
- $(this).toggleClass('bundlesNegativ', 'bundles');
- [...Some Code that isn't relevant...]
- arrangeNote();
- });
- $('#singles').click( function () {
- $(this).toggleClass('singlesNegativ', 'singles');
- [...Some Code that isn't relevant...]
- arrangeNote();
- });
- $('#purchase').click( function () {
- $(this).toggleClass('bundlesNegativ', 'bundles');
- [...Some Code that isn't relevant...]
- arrangeNote();
- });
- });
- function arrangeNote() {
- if($('#bundles').attr('class') == 'bundles'
- && $('#singles').attr('class') == 'singles'
- && $('#purchase').attr('class') == 'bundles') {
- showNote(true);
- } else {
- showNote(false);
- }
- }
- function showNote(isVisible) {
- if(isVisible) {
- $('#noteContainer').show();
- $('#picture').show();
- $('#noteDiv').show();
- } else {
- $('#noteContainer').hide();
- $('#picture').hide();
- $('#noteDiv').hide();
- }
- }
My problem is, that the class of the DOM-Object isn't refreshed until I ask for it in the function "arrangeNote".
I don't know how to fix it because I change the class of the Object
before I call "arrangeNote".
Do you have any suggestions?
Best regards
Tim