JavaScript 点击不同的li,进入同一个页面,显示相应的状态
动态添加的li列表,点击一个列表进去一个功能页面之后有个声音开关图标,点一下变成关闭状态,退出这个页面,再点下一个列表,还进入这个功能页面,但是图标还是关闭状态,怎么实现...
动态添加的li列表,点击一个列表进去一个功能页面之后有个声音开关图标,点一下变成关闭状态,退出这个页面,再点下一个列表,还进入这个功能页面,但是图标还是关闭状态,怎么实现点击不同列表进入的功能页保存的都是不同的状态啊?
//点击图标切换
function voice_onOff() {
$(function() {
if ($('#voiceSpan').attr('class') == 'mui-icon setting_icon icon-shengyintixingkai') {
$('#voiceSpan').attr('class', 'mui-icon setting_icon icon-shengyintixingguan');
localStorage.setItem("VOICESTATE", $('#voiceSpan').attr('class'));
} else {
$('#voiceSpan').attr('class', 'mui-icon setting_icon icon-shengyintixingkai');
localStorage.setItem("VOICESTATE", $('#voiceSpan').attr('class'));
}
});
}
//页面显示切换后的图标
function get_storage_voice() {
$(function() {
if (localStorage.getItem("VOICESTATE") == null) {
$('#voiceSpan').attr('class', 'mui-icon setting_icon icon-shengyintixingkai');
} else {
$('#voiceSpan').attr('class', localStorage.getItem("VOICESTATE"));
}
});
} 展开
//点击图标切换
function voice_onOff() {
$(function() {
if ($('#voiceSpan').attr('class') == 'mui-icon setting_icon icon-shengyintixingkai') {
$('#voiceSpan').attr('class', 'mui-icon setting_icon icon-shengyintixingguan');
localStorage.setItem("VOICESTATE", $('#voiceSpan').attr('class'));
} else {
$('#voiceSpan').attr('class', 'mui-icon setting_icon icon-shengyintixingkai');
localStorage.setItem("VOICESTATE", $('#voiceSpan').attr('class'));
}
});
}
//页面显示切换后的图标
function get_storage_voice() {
$(function() {
if (localStorage.getItem("VOICESTATE") == null) {
$('#voiceSpan').attr('class', 'mui-icon setting_icon icon-shengyintixingkai');
} else {
$('#voiceSpan').attr('class', localStorage.getItem("VOICESTATE"));
}
});
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询