Domanda

I have sourced this working fiddle where a div will slide up and down when a div is clicked. It works great in the fiddle.

http://jsfiddle.net/dRpWv/1/

I have now applied the same code to my website, the div will slide down but clicking the div again does nothing.

$( ".widget_head" ).click(function() {
$( ".widget_body" ).slideDown( "fast", function() {
// Animation complete.
})
})

.widget_head can be found by clicking the "Cars by type" tab on the left side of the page.

È stato utile?

Soluzione

.toggle() has been removed from version 1.9 and you are using jQuery v1.10.2 in your site.

It works in fiddle as ---> fiddle has jQuery v1.8.3 .


Use this code

Fiddle Demo

$(document).ready(function () {
    $("#button").click(function () {
        var txt = ($(this).text() == 'Hide Content') ? 'show Content' : 'Hide Content';
        $(this).text(txt);
        $("#hidden_content").slideToggle("slow");
    });
});

http://api.jquery.com/category/deprecated/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top