我需要在一个大的下拉菜单为顶级H5返回值。如果有人点击了电动工具,我需要一个函数返回系统。我不知道从哪里开始就这个问题和真的可以使用一些帮助。提前致谢。
这里是下拉菜单中的一个的代码。
<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>
你必须为点击一个元素上创建一个事件侦听器。请参阅:https://api.jquery.com/click/
然后函数里面,你可以使用this
来指代一个点击的元素,并使用https://api.jquery.com/parent/
和https://api.jquery.com/child-selector/
找到你所需要的元素。然后使用text()
访问到它的文本值https://api.jquery.com/text/
。