gpt4 book ai didi

JQuery 在单击链接时更改文本

转载 作者:行者123 更新时间:2023-12-01 06:16:58 25 4
gpt4 key购买 nike

我希望文本在点击时改变。当我单击任何链接时,该代码有效,但一旦我单击另一个链接,则什么也没有发生。 jquery 对我来说是新的,这就是我为此苦苦挣扎的原因。提前致谢

$(document).ready(function(){
$("#all-iso").click(function(){
$("#news-h3-change").replaceWith("<h3>ALLE NEWS</h3>");
});
});

$(document).ready(function(){
$("#date-iso").click(function(){
$("#news-h3-change").replaceWith("<h3>DATUM</h3>");
});
});

$(document).ready(function(){
$("#actor-iso").click(function(){
$("#news-h3-change").replaceWith("<h3>SCHAUSPIELER</h3>");
});
});

$(document).ready(function(){
$("#film-iso").click(function(){
$("#news-h3-change").replaceWith("<h3>FILM</h3>");
});
});

最佳答案

   var StatusBar;

$(document).ready(function(){
StatusBar = $("#news-h3-change");
$("#all-iso").click(function(){
StatusBar.html("ALLE NEWS");
});
$("#date-iso").click(function(){
StatusBar.html("DATUM");
});
$("#actor-iso").click(function(){
StatusBar.html("SCHAUSPIELER");
});
$("#film-iso").click(function(){
StatusBar.html("FILM");
});
});

关于JQuery 在单击链接时更改文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16906222/

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