<div id="edit-country-wrapper">
<select id="edit-country" class="form-select" name="country">
<option selected="selected" value="all">All</option>
<option value="canada">Canada</option>
<option value="usa">USA</option>
</select>
</div>
並希望將其更改爲
<div id="edit-country-wrapper">
<ul id="edit-country" class="form-select" name="country">
<li><a class="selected" href="/all">All</a></li>
<li><a class="" href="/canada">Canada</a></li>
<li><a class="" href="/usa">USA</a></li>
</ul>
</div>
這就是我現在所擁有的。
$(document).ready(function() {
$('#edit-country-wrapper select').each(function() {
var $select = $('<div id="location-select" />');
$(this).find('option').each(function() {
var $option = $('<a />');
$option.attr({
href: '?country=' +$(this).attr('value'),
id: 'location-' + $(this).attr('value'),
class: $(this).attr('selected'),
html: $(this).html()
});
$select.append($option);
});
$(this).replaceWith($select);
});
});
我想用無序列表替換下拉列表。我已經在FF & Chrome中工作,但不在IE中。請幫忙!!
什麼東西不能在IE瀏覽器?收到任何錯誤?生成的HTML是否正常? – alex 2010-12-18 00:45:39
IE不會將下拉列表轉換爲列表,但FF和Chrome會將其轉換爲列表。 – canintex 2010-12-20 19:44:11