2013-08-23 156 views
-6

我想知道如何我可以显示不同的按钮,一旦你点击它。例如:jQuery显示/隐藏选择和按钮

<input type="button" value="Submit" id="button1"> 
    <input type="button" value="Submit" id="button2" style="display: none;"> 
    <input type="button" value="Submit" id="button3" style="display: none;"> 

<select id="whatever"> 
<option id="1">1</select> 
<option id="2">2</select> 
<option id="3">3</select> 
</select> 

<select id="whatever2" style="display: none;"> 
<option id="1">1</select> 
<option id="2">2</select> 
<option id="3">3</select> 
</select> 

我想Button1以显示选择ID“无所谓”和按钮2隐藏选择ID =“无所谓”,并显示“whatever2”和按钮3同样的事情。谢谢!

+3

你有没有真正尝试任何东西了吗?阅读.show(),.hide()和.click()上的jQuery文档? – j08691

+0

我试过了,没有任何工作 – Timmy6118CP

+0

告诉我们你试过的东西,@ Timmy6118CP。 – canon

回答

0

button1的

$("#button1").click(function() { 
    $("#whatever").show(); 
}); 

BUTTON2

$("#button2").click(function() { 
    $("#whatever").hide();$("#whatever2").show(); 
}); 

0
$("#buttonId").click(function(){ 
    $("#selectId").show(); 
}) 
-1
<input type="button" value="Submit" onclick="document.getElementById('whatever').style.display = 'block';" id="button1"> 

通过jQuery的

$('#yourbuttonId').click(function() 
    $('#whatever').show(); 
}); 
1
$('input[type="button"]').click(function() { 
    $(this).hide().siblings('input:eq(0)').fadeIn(); 
}) 

检查:fiddle