gpt4 book ai didi

php - 无法使用 JS 定位 div

转载 作者:行者123 更新时间:2023-12-02 19:37:23 25 4
gpt4 key购买 nike

我正在尝试使用 js 来定位嵌套在某些 php 中的 div,但无论我做什么,我似乎都无法定位它。这是供引用的代码:php:

echo "<li>"."<div id=\"countryclick\">". "<a href=\"?Continent=$Continent&Country=$Country\">" . $Country . " ". "</a>" . "</div>"."</li>";

js:

$("#countryclick").click(function(){
$("#country").hide();
$("#city").show();
});

有什么想法吗?预先感谢!

最佳答案

div#countryclick 

是动态创建的,因此您可以使用 .live jQuery 的。喜欢:

$("#countryclick").live("click",function(){
//code here
})

关于php - 无法使用 JS 定位 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10793457/

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