0

So, I have a following div's and function:

<div class="show" style="display:none;"> Show only when </div>

Then, jQuery function:

beforeSend : function(){
        jQuery('.show').html('?????');
    },

How do I make the jQuery function so that it changes the css of class="show" from "display:none" to visible?

Thanks

2
  • Possible duplicate of JQuery Toggle() Commented Oct 28, 2015 at 20:16
  • yeah, could be. Thanks. Commented Oct 28, 2015 at 20:17

2 Answers 2

3

You can try this http://api.jquery.com/show/:

$('.show').show();
Sign up to request clarification or add additional context in comments.

2 Comments

Also note that you can add additional parameters such as duration etc.
i see. Thank you! =) I will read on the link you added. Appreciate it!
2

As Kostas (+1) showed the simplest and most used one to show elements with the use of jquery .show() - you can hide element with .hide() and toggle their display with .toggle() -, to set CSS values with jQuery you can use this function .css()like this:

$(selector).css({'property1':numValue1, 'property2': 'stringValue2'});

for example: JSFiddle

$('#change').on('click', function () {
    $('.something').css({'color': 'orange','background-color': 'maroon'});
});
.something {
    color:white;
    font-size:1.5em;
    background-color:orange;
    padding:2px 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<p class="something">Here is an example</p>
<button id="change">Change CSS</button>

Reference: https://api.jquery.com/css/

1 Comment

Thank you for the awesome example and explanation! =) Learned something new!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.