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');
}
}
};

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');
        }
    });
});

Dude, thank you very much! It's working! Yeah i messed up with the bracket placing (facepalm)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.