0

I can't seem to hide my paragraph the way i wanted it to be. I checked my code a lot of times and it seems correct. I don't know why it's not running.

<!DOCTYPE html>
<html lang="en">
<html>

<head>
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript" src="jquery/toggle.js"></script>
</head>

<body>
<input type="button" value="hide" id="toggle">
<p id="paragraph">I want to hide!</p>
</body>
</html>

another page which has the toggle code

$(document).ready(function()){
$('#toggle').click(function(){
  var value = $('#toggle').attr('value');
  $('#paragraph').toggle('fast');

  if (value == 'hide'){
    $('#toggle').attr('value', 'show');
  }
  else if (value == 'show')
  {  
    $('#toggle').attr('value', 'hide');
}
}
};

Edited by Eggstraordinary

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by Eggstraordinary
0

Try execute this code. You wrong wrote a bracket for function ready() and click()

$(document).ready(function()
{
    $('#toggle').click(function()
    {
        var value = $('#toggle').attr('value');
        $('#paragraph').toggle('fast');

        if (value == 'hide'){
            $('#toggle').attr('value', 'show');
        }
        else if (value == 'show')
        {  
            $('#toggle').attr('value', 'hide');
        }
    });
});
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.