How onclick some button, id=i_1, to toggle visibility of some div with id=d_1 (to show slide right while appearing)? I need开发者_Python百科 to use JQuery for this.
It's difficult to understand exactly what you're after from your question, but perhaps something like this will get you started:
$("#i_1").click(function() {
$("#d_1").animate({ width:'toggle' }, 500);
});
Here's an example showing that in action.
If you add some more information and some sample code to your question, it will be easier to provide a more accurate answer!
The devious side of me wanted to code this dynamically
http://fiddle.jshell.net/Vcyj8/1
HTML
<input type="button" value="button 1" id="i_1"/><br>
<div id="d_1">div 1 text description</div>
<input type="button" value="button 2" id="i_2"/><br>
<div id="d_2">div 2 text description</div>
<input type="button" value="button 3" id="i_3"/><br>
<div id="d_3">div 3 text description</div>
<input type="button" value="button 4" id="i_4"/><br>
<div id="d_4">div 4 text description</div>
CSS
div {
display:none;
}
input {
padding:5px;
}
jQuery
$("[id^='i_']").click(function(){
$("#d_"+this.id.substr(2)).slideToggle("fast");
})
精彩评论