gpt4 book ai didi

javascript - 无法使用jquery选择元素段落

转载 作者:行者123 更新时间:2023-12-02 17:56:57 25 4
gpt4 key购买 nike

<html>
<head>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});

});
function func(){
var s = "<p id=" + id +">"+"<center>"+"<h2><b>Topic :</b></h2>"+message+"</center></p><br>";
document.getElementById("stat").innerHTML+=s;

}
</script>



</head>
<body>
//call function func
<pre id="stat" > </pre>
</body>
</html>

伙计们,函数 func 应该创建一个 id 为“id”的段落,内容作为标签内的消息,id 为“stat”..它工作得很好但我无法使用“Jquery”选择器来使用

标签上的点击功能:/!我插入 in 的原因是我需要解释器将“\n”视为新行。为什么会这样,不起作用?

还有其他方法吗?

最佳答案

试试这个,

$(document).ready(function(){
$(document).on('click','p',function(){
$(this).hide();
});
});

关于javascript - 无法使用jquery选择元素段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20886182/

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