我正在尋找一個(顯示/隱藏)按鈕來顯示這樣一個表:顯示/隱藏按鈕
點擊在(顯示):
Button (Show) changes to (Hide) and the table appears.
點擊在(隱藏):
Button (Hide) changes to (Show) and the table disappears.
我正在尋找一個(顯示/隱藏)按鈕來顯示這樣一個表:顯示/隱藏按鈕
點擊在(顯示):
Button (Show) changes to (Hide) and the table appears.
點擊在(隱藏):
Button (Hide) changes to (Show) and the table disappears.
<input type="button" id="button" value="hide" />
$(function(){
var button = true;
$('#button').on('click', function(){
$('#button').toggle();
if (button){
button = false;
$('#button').val('hide');
} else{
button = true;
$('#button').val('show');
}
});
})
方式放緩,但現在,我做媒體鏈接小提琴:
$(document).ready(function() {
$('.toggle').click(function(){
var collapse_content_selector = $(this).attr('href');
var toggle_switch = $(this);
$(collapse_content_selector).toggle(function(){
if($(this).css('display')=='none'){
toggle_switch.html('Show');
}else{
toggle_switch.html('Hide');
}
});
});
});
它也在這裏工作,非常感謝你! – user3050478
非常感謝GuyT! – user3050478