如何使用jquery切换div? [英] How to toggle a div using jquery?

查看:84
本文介绍了如何使用jquery切换div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii,



$(document).ready(function(){



$( '#showHide')。toggle(function(){

$(this).val('Show');

$('#divComments')。hide( );

},function(){

$(this).val('Hide');

$('#divComments' ).show();



});

});



我正在上面的代码...因为我在document.ready中编写代码,它首先自动隐藏div ...如果我删除document.ready它将无法工作.. plz建议

Hii ,

$(document).ready(function () {

$('#showHide').toggle(function () {
$(this).val('Show');
$('#divComments').hide();
}, function () {
$(this).val('Hide');
$('#divComments').show();

});
});

I am doing above code ... since i am writing code inside document.ready its automatically hidding the div at first ... and if i remove document.ready it wont work .. plz suggest

推荐答案

(document).ready(function(){


(document).ready(function () {


('#showHide')。 toggle(function(){
('#showHide').toggle(function () {


(this).val('Show');
(this).val('Show');


这篇关于如何使用jquery切换div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆