Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery & CSS - Remove/Add display:none

Tags:

jquery

css

I have a div with this class :

.news{
  width:710px; 
  float:left;
  border-bottom:1px #000000 solid;
  font-weight:bold;
  display:none;
}

And I'd like with some jQuery methods remove that display:none; (so the div will showed) and than add it again (so the div will shadow).

How can I do it? Cheers

like image 622
markzzz Avatar asked Feb 20 '11 19:02

markzzz


People also ask

What is jQuery used for?

jQuery is a lightweight, "write less, do more", JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on your website. jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.

Is jQuery the same as JavaScript?

The main difference among the three is that JavaScript is client-side, i.e., in the browser scripting language, whereas jQuery is a library (or framework) built with JavaScript.

Is jQuery still used in 2021?

6 Reasons Why We Still Use jQuery in 2021. jQuery has been around for over 10 years, which is a long time for a code library. It's still one of the most popular JavaScript libraries in web development. We love jQuery here at Atypic and still utilize it in our projects.

Which is better js or jQuery?

Though JavaScript is the basic language from which jQuery has evolved, jQuery makes event handling, DOM manipulation, Ajax calls much easier than JavaScript. jQuery also allows us to add animated effects on our web page which takes a lot of pain and lines of code with JavaScript.


2 Answers

To hide the div

$('.news').hide();

or

$('.news').css('display','none');

and to show the div:

$('.news').show();

or

$('.news').css('display','block');
like image 142
Snehal Ghumade Avatar answered Sep 29 '22 01:09

Snehal Ghumade


jQuery provides you with:

$(".news").hide();
$(".news").show();

You can then easily show and hide the element(s).

like image 40
JCOC611 Avatar answered Sep 28 '22 23:09

JCOC611