【发布时间】:2015-03-11 12:00:51
【问题描述】:
我想在屏幕上显示所有选择的选项值。我进行头脑风暴的一种方法如下:
<select size="4">
<option></option>
<option></option>
<option></option>
<option></option>
</select>
我遇到的问题是,是的,所有内容都显示出来了,但它们都不是 clicable。我希望当其中一个被点击时,它将用户重定向到另一个 url。我还希望每个选项都成为一面旗帜。
我这样做的原因是因为我已经有 10 个图像,称为 10 个城市,并且我想记录用户的城市选择,以便我能够为他们填充正确的社区。p>
更新:
以下是各自图片的链接:
<a href="createEventRestaurant.html""><img id="selectNeighbourhood1" src="content/San-Francisco/berkeleyCampanile.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/castro.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood"src="content/San-Francisco/dogpatch-tasting-room.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood"src="content/San-Francisco/FD1.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Fishermans-Wharf.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Golden-Gate-Park.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Hayes-Valley.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Marina.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Mid-market.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Mission-district.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Noe-Valley.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Pacific-heights.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Russian-hill.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Soma.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Stanford-university.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Sunset-district.jpg"></a>
<a href="createEventRestaurant.html" target="_self"><img id="selectNeighbourhood" src="content/San-Francisco/Tenderloin.jpg"></a>
【问题讨论】:
-
图片在哪里?什么是可点击的?您要将用户重定向到的网址在哪里?您需要显示所有相关的源代码和信息,以便我们为您提供帮助。这里我们只有一个 I want 列表和一个空的 select 元素......
-
我认为在那种情况下
select不是你最好的选择,你为什么不能使用ul li组合来创造你想要的视觉效果 -
感谢您的回复。为了澄清,我在我的初始帖子下添加了一个更新,显示带有相关链接的图像。我想使用 select 的主要原因是,使用它的 ID 我可以识别哪个项目被点击了
-
我看到的第一个问题,您对多个元素有相同的
id。id用于标识特定元素(其中一个)如果您想分配某些东西,请将它们分配到一个组中,请使用class。将元素更改为类,您可以使用jQuery在一个函数中获取元素 -
id 必须是唯一的。如果您想在多个事物上使用类似的样式,请使用类,而不是 id
标签: javascript jquery css html