技術メモ(主に自分向け)

短期記憶の自分向けの技術メモです。

htmlのテキストを抽出する

Auraコンポーネント(html)内のテキストをjavascripで抽出する。


(例)
・html側

<div class="test_tree1">
 <p class="test_tree1_content">テスト1</p>
</div>
<p class="test_tree2">テスト2</p>

javascript

$("test_tree1_content").on("click", function() {
 let idText = $(this).parent().next().text();
});

⇒テスト2が取れる。

this:test_tree1_content
parent:test_tree1
next:test_tree2
text:テスト2