Doubt about jquery code

Asked

Viewed 81 times

-4

People is like this when the user clicks on the red div that is the div_2 it would disappear and appear the green div that is the div_1, but this giving an error the red div is not disappearing.

<html>
<head>

<style>
.div_1 { width: 100px; height: 100px; background-color: #060; }
.div_2 { width: 100px; height: 100px; background-color: #300; }
</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

<script>
$(document).ready(function(){
$(".div_1").css("display", "none");
});
$(document).ready(function($) {
$('.div_2').click(function(){
$(".div_1").css("display", "block");
$(".div_2").css("display", "nome");
});
});
</script>


</head>
<body>

<div class="div_1"></div>
<div class="div_2"></div>

</body>
</html>
  • 2

    Again? nome != none...

  • 1

    KKKKKKKKKKKKKKKKK Dude hadn’t seen this.

  • 5

    This question seems to be out of date because it is about a typo and will hardly be useful to other people.

  • 1

    But the mistake is different from before

  • Check out this other comment that I did. I think it also applies to your case.

  • 1

    @But you’re totally wrong, I’ve been searching for a solution and nothing.

  • Okay, it was just an impression... good luck!

Show 2 more comments

1 answer

3


The problem is in the code $(".div_2").css("display", "nome");, you meant none.

Additionally see that jQuery has convenient methods for displaying and hiding elements, respectively .show() and .Hide():

$(".div_1").show();
$(".div_2").hide();
  • 1

    I don’t even make fun of myself

  • 1

    Look at 2 o'clock in that code

  • 1

    Anthony, I didn’t know this required method =D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.