我刪除海峽,在我自己的網站,有些鏈接到RSS種子的......這樣的:jQuery的 - 添加/上變化
ALL
example.com/rss
NEWS
example.com/rss?type=1
ARTICLES
example.com/rss?type=2
在同一頁我要插入一些過濾器...所以我有一個選擇:
<select class="rss-list-platform">
<option value="">All</option>
<option value="1">Xbox</option>
<option value="2">PlayStation</option>
</select>
我要尋找一個jQuery代碼,將增加「&平臺= VAL」原來的鏈接,但是,如果選擇「全部」選項挑...如果有的話,我們應該刪除「& platform = val」。
目前我有下面的代碼,但它不斷添加遍及文本...並不刪除它。
$(".rss-list-platform").change(function(){
var ref_this = $(this);
var original_str = "";
$(".rss-list input").each(function(){
original_str = $(this).val();
add_str = original_str + "&platform=" + ref_this.val();
$(this).val(add_str);
});
});
你能解釋一下嗎?嘗試序列化()選擇$(「。rss-list-platform」)。serialize()不會輸出任何內容。 – user2840318
我更新了你的jsfiddle,所以它使用了serialize()。看看它,希望你會發現它有用! http://jsfiddle.net/PMCWw/2/ – Streamside