我需要在一个大的下拉菜单中返回顶层h5的值。如果有人点击Power Tools,我需要一个函数来返回系统。我不知道从哪里开始做这件事,真的需要一些帮助。提前谢谢。
下面是其中一个下拉菜单的代码。
<div class="col">
<div class="list-group pl-4">
<h5 class="font-weight-bold mt-4 mb-2 text-ar-form-text">System</h5>
<a class="mt-2 text-ar-form-text" href="/instruments">Instruments</a>
<a class="mt-2 text-ar-form-text" href="/radio">Radio</a>
<a class="mt-2 text-ar-form-text" href="/power-tools">Power Tools</a>
<a class="mt-2 text-ar-form-text" href="/fluid">Fluid</a>
</div>
</div>发布于 2018-02-10 06:03:05
您必须为单击a元素创建一个事件侦听器。请参阅:https://api.jquery.com/click/
然后在函数内部,您可以使用this来引用所单击的元素,并使用https://api.jquery.com/parent/和https://api.jquery.com/child-selector/来查找所需的元素。然后使用text()访问其文本值https://api.jquery.com/text/。
https://stackoverflow.com/questions/48714661
复制相似问题