我正在使用jQuery移動,並且在不同的頁面中有類似的<li>
類。像這樣:訪問不同jQuery頁面中的類元素
<div data-role="page" id="engineering">
<h1 style="color:black;"> Departments </h1>
<ul data-role="listview" data-theme="a" data-split-theme="b" data-split-icon="plus" data-inset="true">
<li class="departments"><a href="#department">Department of Electrical and Electronics</a></li>
<li class="departments"><a href="#department">Department of Computer Science</a></li>
</ul>
</div>
<div data-role="page" id="medicine">
<h1 style="color:black;"> Departments </h1>
<ul data-role="listview" data-theme="a" data-split-theme="b" data-split-icon="plus" data-inset="true">
<li class="departments"><a href="#department">Department of Medical Sciences</a></li>
</ul>
</div>
使用$('departments').text()
,這將返回類部門的所有文本。我如何獲得我點擊的特定列表元素的文本?