gpt4 book ai didi

javascript - 我怎样才能简化这个 jQuery JavaScript 代码?

转载 作者:行者123 更新时间:2023-11-30 07:02:44 24 4
gpt4 key购买 nike

<分区>

我对使用 jQuery/JavaScript 进行编码有点陌生。我已经设法编写了下面的代码,但我认为有一种更简单的方法可以将其写下来。有人可以告诉我怎么做吗?

$(document).ready(function(){
$(".btn_home").click(function(){
$("#article1").fadeIn();
$("#article2").fadeOut();
$("#article3").fadeOut();
$("#article4").fadeOut();

$("#blended").fadeOut();
$("#contact").fadeOut();
});

$(".btn_prt").click(function(){
$("#article1").fadeOut();
$("#article2").fadeIn();
$("#article3").fadeOut();
$("#article4").fadeOut();


$("#over").fadeIn();
$("#blended").fadeOut();
$("#contact").fadeOut();
});

$(".btn_blog").click(function(){
$("#article1").fadeOut();
$("#article2").fadeOut();
$("#article3").fadeIn();
$("#article4").fadeOut();

$("#over").fadeOut();
$("#blended").fadeIn();
$("#contact").fadeOut();
});

$(".btn_abt").click(function(){
$("#article1").fadeOut();
$("#article2").fadeOut();
$("#article3").fadeOut();
$("#article4").fadeIn();

$("#over").fadeOut();
$("#blended").fadeOut();
$("#contact").fadeIn();
});
});

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com