我有一些span標籤,我希望能夠點擊它們並切換div。我無法將ID放在span標籤上。我該如何根據這些獨特的跨度上的標題來做到這一點?這是我的HTML。使用基於span標籤標題的onclick
<span title="Silver" class="swatchColours swatchOneColour showPreview">
<span style="background-color:#cccccc;" class="swatchColour swatchColour_1"> </span>
</span>
<span title="Black" class="swatchColours swatchOneColour showPreview">
<span style="background-color:#000000;" class="swatchColour swatchColour_2"> </span>
</span>
<div id="colour_one">Silver</div>
<div id="colour_two">Black</div>
可能重複http://stackoverflow.com/questions/6431891/select-an-element-by- title-in-jquery) –