This is probably a very simple question.
here's my code.
$( document.body ).click(function () {
if ( $( ".more" ).first().is( ":hidden" ) ) {
$( ".compleatelist" ).slideDown( 6000 );
} else {
$( ".compleatelist" ).hide();
}
});
However, the button triggers when I click on ANY click event in the whole page not my ".more" button?
What am I missing here?
$( document.body ).click() <-- This means you are firing click on all clicks on the document body
You probably want
$(".more").click(function(e){
// $(this) <-- this is the element you just clicked on
});
This will only fire an event when an element containing the more
class is clicked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.