The toggle function isn't working. on page load the text 'Link' is visible for just a sec and disappears. Then 'No' is displayed

+2 Rizwan Khan · October 10, 2015
Below is the HTML and JS code.

HTML:
<!doctype html>
<html lang="en">
<head>
<title>JQuery Example</title>
<meta charset="utf-8"/>
</head>

<body>

<a href="#" id="click_me">Link</a>
<div id="click_event"></div>

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

</body>
</html>

JS code :

$('#click_me').toggle(function(){
$('#click_event').html('Yes');
}, function(){
$('#click_event').html('No');
});

Post a Reply

Replies

Oldest  Newest  Rating
0 Scott Walker · November 20, 2015
Didn't work for me either, so I did this workaround:

$('#button').click(function () {
    if ($('#para').is(':visible')) {
        $('#para').hide();
        $('#button').prop("value", "show");
    }
    else {
        $('#para').show();
        $('#button').prop("value", "hide");
    }

});





<input id="button" type="button" value="hide" />

    <p id="para">lalalallaa</p>
0 abdullah abadilah · November 12, 2015
have you get the solution my friend ?
  • 1

Javascript

107,345 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators