Tag: 切换

jQuery .toggle()与第二个函数没有按预期工作?

我正在尝试创建一个按钮来显示/隐藏它下方的div,一切正常,我只是在最后一点挣扎! 我需要区分它是一个节目还是隐藏动作所以我可以将变量传递到别处,这就是我所拥有的…… $(this).find(‘.hide-close’).click( function() { $(this).siblings(‘.dragbox-content’).toggle(function() { alert($(this).parent().attr(“id”) + ‘ Show’); },function() { alert($(this).parent().attr(“id”) + ‘ Hide’); } ); }) .end() }); 如果使用以下代码,取出toggle()中的第二个函数,它有效吗?! 但后来我没有显示/隐藏变量。 $(this).find(‘.hide-close’).click( function() { $(this).siblings(‘.dragbox-content’).toggle(function() { alert($(this).parent().attr(“id”) + ‘ Show’); } ); }) .end() }); 在此先感谢您的帮助,希望这是我看不到的非常简单! 🙂

jQuery hover show div toggle

我正在这个非常简单的网站上工作但是我已经有一段时间了,因为我摆弄了jQuery,我想我在这里做错了。 在这里你可以用jsFiddle预览这个想法http://jsfiddle.net/rGb34/1/ jQuery存在一些问题。 如果将鼠标hover在黄色按钮上,黄色内容将开始翻转。 如果你将鼠标hover在一个按钮上然后退出它,则div会消失(由于切换function)但我希望最后一个div处于活动状态,即使没有hover。 有没有人对我有好的建议,所以我可以完成这个?

单击父时隐藏所有可见的

晚上好 我有ul的forms的ul,li和嵌套下拉菜单的基本结构。 我想要做的是,当点击父li时,将显示子ul。 当再次点击li时,孩子会隐藏。 所以这就是我到目前为止所做的 $(document).ready(function() { $(“ul#glass-buttons li”).toggle(function() { $(“ul”, this).show(); }, function () { $(“ul”, this).hide(); }); }); 它工作得很好,唯一的问题是有多个子下拉菜单。 因此当一个人打开并且我点击另一个父李时,两个孩子的ul都保持打开并重叠。 任何人都可以推荐最好的方法,当我们不再需要时,我可以隐藏所有可见的ul。 此外,当用户单击文档中的任何位置时,隐藏任何打开的ul的最佳方法是什么? 首先十分感谢。 =]

如何使用JQuery显示带有单选按钮的隐藏表行

我有多个表行,每行有一组单选按钮(批准和拒绝)。 当我选择拒绝时,我想在它下面显示一个隐藏的tr,我正在使用jquery将HTML插入到tr中。 当我选择批准时,应该再次隐藏tr。 我不能让它完全按照我解释的方式工作,当我在批准和拒绝单选按钮之间切换时,隐藏的tr会显示在所有行上。 我希望它只显示在我点击的单选按钮下面。 我的小提琴: http : //jsfiddle.net/4A7TD/ HTML: APP   REJ APP   REJ JQuery的: $(‘.hiddenColumn’).hide(); $(‘input[type=radio]’).change(function() { if ($(this).val() == ‘reject’) { $(‘.hiddenColumn’).show(); var showColumn = ($(this).closest(‘tr’).next(‘tr’)); showColumn.html(‘*Reason for Rejection’); } else if ($(this).val() == ‘approve’) { ($(this).closest(‘tr’).next(‘tr’)).hide(); }; });

Google地图多边形显示/隐藏切换复选框

我正在尝试使用复选框输入进行简单的多边形开/关切换,但我无法使以下代码有效。 我在谷歌搜索并找到了一些解决方案,但没有一个对我有用。 html, body, #map-canvas{height: 100%; margin: 0px; padding: 0px; height: 590px;} function toggleLayer(firLayer,id) { if ($(‘#’+id).is(‘:checked’)) { firLayer.setMap(map); } else { firLayer.setMap(null); } } function initialize() { var mapOptions = { zoom: 4, center: new google.maps.LatLng(-14.886436490787712, -47.2685546875), mapTypeId: google.maps.MapTypeId.TERRAIN }; var map = new google.maps.Map(document.getElementById(‘map-canvas’), mapOptions); var firCTB = [ new google.maps.LatLng(1.03333333, -40.98333333), new […]

当用户点击其他地方时,如何使用jquery隐藏ul

我有这个代码来切换ul可见性。 $(‘.cliackable’).click(function(){ $(this).find(‘ul’).toggle(); }); $(‘.cliackable’).click(function(event) { event.stopPropagation(); }); 如果用户在ul外部点击,我该如何切换? 我尝试使用这里的答案,但无济于事: jQuery切换隐藏点击其他地方 更新 我的CSS看起来像这样 html, body {height:100%;width:100%;margin:0;} #navigation-main {width:65px;margin-left:10px;} #navigation-main .sf-menu-main li ul {display:none;} #navigation-main .sf-menu-main li li {background:#e73420;border-top:1px solid rgba(0,0,0,0.1); width: 235px; clear:both; padding:5px 0px 5px 15px; color:#fff;} #navigation-main .sf-menu-main li li a {width: 250px; padding:5px 10px 5px 15px; color:#fff;} 和HTML Menu Home Events 我尝试使用你的js但没有工作

Jquery在3个div上切换

HTML: First Content second Content Third Content JS: $(“div.one”).click (function(){ $(“#bottomContent2”).hide(); $(“#bottomContent3”).hide(); $(“#bottomContent”).animate({width: “toggle”}, 1000); }); $(“div.two”).click (function(){ $(“#bottomContent”).hide(); $(“#bottomContent1”).hide(); $(“#bottomContent2”).animate({width: “toggle”}, 1000); }); $(“div.three”).click (function(){ $(“#bottomContent”).hide(); $(“#bottomContent2”).hide(); $(“#bottomContent3”).animate({width: “toggle”}, 1000); }); 我有以下jQuery代码,当单击每个div时,它将为其自己的相应div项设置动画并关闭可能已经打开的任何其他div但我相信有更好的方法来编码它并使其比我已经做好了。 任何帮助将不胜感激。

缩略图hover时切换图像?

请看这个小提琴: http : //jsfiddle.net/rabelais/e47xq/2/ 当用户在缩略图上hover时,我想显示缩略图的大图像。 以下是我的出发点。 有什么建议怎么做? 在我的最终版本中,可能有20个缩略图,所以我需要尽可能简洁的代码。 $(“.thumnails”).on(“mouseover mouseout”, “a”, function () { $(‘#’).toggle(); });

jquery暂停/恢复计时器切换

我有这个简单的倒数计时器 – $(document).ready(function() { var Clock = { totalSeconds: 800, start: function () { var self = this; this.interval = setInterval(function () { self.totalSeconds -= 1; $(“#hour”).text(Math.floor(self.totalSeconds / 3600)); $(“#min”).text(Math.floor(self.totalSeconds / 60 % 60)); $(“#sec”).text(parseInt(self.totalSeconds % 60)); }, 1000); }, pause: function () { clearInterval(this.interval); delete this.interval; }, resume: function () { if (!this.interval) this.start(); […]

jquery切换所有内容

嗨,我正试图切换内容。 例如:如果我点击它打开的第一个内容,其余内容保持关闭状态,如果我点击第二个内容,第一个内容关闭,第二个内容打开,它会继续,直到我没有更多内容。 我的问题是,当我点击“+”时,它会打开所有内容。 这是我的HTML Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut diam lacus, auctor vitae urna eget, sollicitudin ullamcorper eros. Ut mattis dignissim tellus, ac scelerisque turpis fermentum vel. Etiam faucibus eros adipiscing turpis commodo, quis pulvinar ligula ultrices. Suspendisse non felis in nisl mollis tristique vitae vitae turpis. Nunc eleifend fringilla lectus […]