每次用戶訪問選項卡菜單時,都會嘗試刷新單選按鈕的列表。第一次訪問樣式是可以的,但它們表現得像複選框,並且當其他單選按鈕被點擊時不能被取消選中。單選按鈕不會動態應用樣式
我試圖把refresh();
方法,但它仍然無法正常工作。
你可以看到JSFIDDLE
任何建議的演示?謝謝。
$('.export_tab').click(function(){
$("#radios_wrapper").children().remove(); //Remove all previous radio buttons
for(var i in localStorage) //Looping through the localStorage
{
dataIndex = JSON.parse(localStorage[i]).index;
dataName = JSON.parse(localStorage[i]).name;
//Then insert a new one
$("#radios_wrapper").append('<input type="radio" value="'+dataIndex+'" name="'+dataIndex+'" id="radio'+dataIndex+'"/><label for="radio'+dataIndex+'">'+dataName+'</label>');
}
});
這是HTML
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" id='radios_wrapper'>
</fieldset>
</div>
提供演示:[JS Bin](http://jsbin.com/),[jsFiddle](http://jsfiddle.net/)等。 – 2013-03-14 05:04:32
http://jsfiddle.net/w4gQa/1/幹得好。 – 2013-03-14 05:22:51