0
此代碼在第一次點擊時正常工作。當重複它的作品時,只需在第二次點擊相同的元素。 HTML單擊操作可以在第二次點擊時起作用
<div id="monthly-table">
<a href="#" class="monthly active">Monthly</a>
<a href="#" onclick="subscriptionTable(this)" class="yearly">Yearly</a>
<h1>Monthly</h1></div><div id="yearly-table" style="display:none">
<a href="#" onclick="subscriptionTable(this)" class="monthly">Monthly</a>
<a href="#" class="yearly active">Yearly</a>
<h1>Yearly</h1></div>
SCRIPT
function subscriptionTable(el) {
$(el).on('click', function() {
if ($('#yearly-table').is(':hidden')) {
$('#yearly-table').show();
$('#monthly-table').hide();
} else {
$('#yearly-table').hide();
$('#monthly-table').show();
}
return false;
});
};
爲什麼不喜歡這個http:// http://jsfiddle.net/eLj3v64g/ – guradio