Javascript Neet帮助在Jquery中创建父/子结构
我有以下HTML: 我试图在单击编辑按钮后将Javascript Neet帮助在Jquery中创建父/子结构,javascript,jquery,Javascript,Jquery,我有以下HTML: 我试图在单击编辑按钮后将{{$comment->comment}}发送到Jquery函数。我需要帮助完成以下结构: Comment = event.target.parentNode.childNodes[1]; {{$comment->user->first_name}{{{$comment->user->last_name} {{$comment->comment} {{$comment->created_at} 如果要修复无效的HTML(如注释中所述,不能在中),
{{$comment->comment}}
发送到Jquery函数。我需要帮助完成以下结构:
Comment = event.target.parentNode.childNodes[1];
{{$comment->user->first_name}{{{$comment->user->last_name}
{{$comment->comment}
{{$comment->created_at}
如果要修复无效的HTML(如注释中所述,
不能在
中),您可以获得如下注释:
document.getElementById("eid").onclick = function(e) {
let comment = e.target.closest(".p-3").getElementsByTagName("p")[0].innerHTML;
console.log(comment);
};
或者,如果要使用jQuery:
$("#eid").on("click", function(){
let comment = $(this).closest(".p-3").find("p").text();
console.log(comment);
});
请单击编辑,然后单击
[]
代码段编辑器并更改实际HTML内容的模板。什么事件将触发您需要的代码?您的HTML无效。您不能在Span中包含div,因为我正在用现成的模板进行编辑。@AbdallahSakre很高兴我能提供帮助:)