Home  >  Article  >  Web Front-end  >  Toggle a div to show or hide and can be expanded into a custom drop-down box_jquery

Toggle a div to show or hide and can be expanded into a custom drop-down box_jquery

WBOY
WBOYOriginal
2016-05-16 17:22:461032browse
Copy code The code is as follows:

$(function(){
//toggle div
$("#gga").click(function(event){
event.stopPropagation(); //Stop bubbling events
$(".toggleoption").slideToggle("fast");
});

//slideup div
$(document).click(function(event) {
var eo = $(event.target);
if($( ".toggleoption").is(":visible") && eo.attr("class") != "toggleoption" && !eo.parent(".toggleoption").length) {
$('.toggleoption ').slideUp("fast");
}
});
})

event.preventDefault(); //Cancel the default action of the event.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn