How to change visibility of a div css to visible with jQuery

后端 未结 4 1237
说谎
说谎 2021-02-13 15:14

I have NEXT and PREVIOUS buttons on my screen. When the page initially loads I want the Previous button to be hidden and as soon as user clicks the Next button I want Previous b

相关标签:
4条回答
  • 2021-02-13 15:38

    Havde you tried $("#navigationButtonTop").show();

    0 讨论(0)
  • 2021-02-13 15:43

    firstly you have not closed your if statement and navigationButtonTop is a class not a id try this.

    if (that.get("pageCounter") >= 1) {
         $(".navigationButtonTop").css("visibility", "visible");
    }
    

    as the OP has edited his question the new answer would be:

    $(function() {
      $(".navigationButtonTop").css("visibility", "visible");
    });
    
    0 讨论(0)
  • 2021-02-13 15:46

    In your JS you use ID ("#" sign before selector's name). But in your CSS you use CLASS (dot sign before selector's name).

    Try to use "#" in both cases (or dot accordingly).

    0 讨论(0)
  • 2021-02-13 15:50

    First of all, the code of how you actually like to trigger the event, would be nice to know. Maybe the trigger is not working at all?

    Additionaly you addressed differently. In CSS navigationButtonTop is a class (see the ".") and in JS it's an id (see the "#"). Is this the culprit in your atual code? If not I'll assume it's an id further...

    For more readability try to move your visibility: hidden to an extra hidden class. So you just can trigger:

    $("#navigationButtonBottom").on('click', function() {
      $("#navigationButtonTop").removeClass('hidden');
    });
    

    And in you HTML add the class hidden to your button

    #navigationButtonTop.hidden { visibility:hidden; }
    

    Or do it using javascript:

    jQuery(document).ready( function($) {
      $("#navigationButtonTop").addClass('hidden');
    })
    
    0 讨论(0)
提交回复
热议问题