toggle

jQuery Toggle State

限于喜欢 提交于 2019-11-27 12:27:53
Here's the quick and skinny of my issue: $("a").toggle(function() { /*function A*/ }, function() { /*function B*/ }); Inside function A a form is displayed. If the user successfully completes the form, the form is hidden again (returning to it's original state). Inside function B the same form is hidden. The theory behind this is that the user can choose to display the form and fill it out, or they can click again and have the form go back into hiding. Now my question is this: currently, if the user fills out the form successfully--and it goes into hiding--the user would have to click on the

jQuery toggle animation

强颜欢笑 提交于 2019-11-27 12:23:19
I have this jQuery: $(document).ready(function() { $("#panel").hide(); $('.login').toggle( function() { $('#panel').animate({ height: "150", padding:"20px 0", backgroundColor:'#000000', opacity:.8 }, 500); }, function() { $('#panel').animate({ height: "0", padding:"0px 0", opacity:.2 }, 500); }); }); This is working fine, but I need to extend the functionality a little. I want to also similarly manipulate another div's properties in sync with the #panel div. I tried adding two more functions relating to the secondary div, but I just got a 4-phase toggle...haha! Forgive my ignorance! Thanks

Click toggle with jQuery

限于喜欢 提交于 2019-11-27 10:27:11
I've used a hover function where you do x on mouseover and y and mouseout. I'm trying the same for click but it doesn't seem to work: $('.offer').click(function(){ $(this).find(':checkbox').attr('checked', true ); },function(){ $(this).find(':checkbox').attr('checked', false ); }); I want the checkbox to be checked when clicking on a div , and unchecked if clicked again - a click toggle. This is easily done by flipping the current 'checked' state of the checkbox upon each click. Examples: $(".offer").on("click", function () { var $checkbox = $(this).find(':checkbox'); $checkbox.attr('checked',

What is alternative to use after jQuery 1.9 removed .toggle(function,function)?

时间秒杀一切 提交于 2019-11-27 09:02:47
Hi i'm trying to create something that will alternate shrinking and growing on every click, but i'm using jQuery 1.9 for my website. the .toggle(function,function) function was removed from jQuery 1.9 , so I'm not really sure what I should use instead. Any help would be great. Thanks jsfiddle (uses old code, the jquery 1.8 version): http://jsfiddle.net/TNAC6/ new jsfiddle (jquery 1.9): http://jsfiddle.net/TNAC6/1/ Here is my code I'm trying to make toggle. Basically the thing i'm toggling is a circle div. (function($){ $.fn.createToggle = function(size) { var ele = $(this); var oldSize = ele

Toggle visibility property of div

让人想犯罪 __ 提交于 2019-11-27 08:48:47
I have an HTML 5 video in a div. I then have a custom play button - that works fine. And I have the video's visibility set to hidden on load and visible when the play button is clicked, how do I return it to hidden when the play button is clicked again? function showVid() { document.getElementById('video-over').style.visibility = 'visible'; } #video-over { visibility: hidden; background-color: rgba(0, 0, 0, .7) } <div id="video-over"> <video class="home-banner" id="video" controls=""> <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' /> <source src="http://video-js

Javascript styling toggle doesn't work first click

喜欢而已 提交于 2019-11-27 08:46:52
问题 I'm making this little html app with a sidebar menu that pops up on click. It works fine except that it only starts to work after the second click. On the first click nothing happens. CSS: #menubalk{ margin-left: -260px; } HTML: <div id="menubutton"> <img src="design/images/menu.png" id="menu" onclick="toggle()" alt=""/> </div> <div id="menubalk"> <h5>Menu</h5> </div> Javascript: function toggle () { var el = document.getElementById("menubalk"); var kop = document.getElementById("kop"); var

toggle() not working for content loaded with ajax?

馋奶兔 提交于 2019-11-27 08:28:31
问题 $('.slideArrow').toggle(function (event) { //some code }, function (event) { //some code }); This works fine for content which are loaded on page-load.But the same function does not work for content loaded with ajax.It just does not intercept the click. What should I do? In an other scenario,i faced a same problem(not for toggle,for click) and sorted it this way.I dont know what to do for toggle? $('.common-parent').on('click','.target-of-click',function(){ //some code }) 回答1: The flag method

jQuery toggle animation doesn't work on new jQuery

匆匆过客 提交于 2019-11-27 08:26:51
问题 I have problem with this toggle on jQuery 1.8.2 i works but on 1.11.0 no. Can you help me what is wrong? $('.open').toggle(function () { $('.obj').animate({ top: "0" }, 500); },function () { $('.obj').animate({ top: "-8%", }, 500); }); 回答1: As mentioned in the comments you will need to do this using the click method. Here is an example that uses the element's data to store the state: $('.open').on('click', function(){ var isToggled = $(this).data('isToggled'); if(isToggled){ $('.obj').animate

Using jQuery, how do you find only visible elements and leave hidden elements alone?

家住魔仙堡 提交于 2019-11-27 07:57:30
So I start with items 1-4: <div class="someDiv bold italic" style="display: none;">Lorem</div> <div class="someDiv regular italic" style="display: block;">Lorem</div> <div class="someDiv bold" style="display: none;">Ipsum</div> <div class="someDiv regular" style="display: block;">Ipsum</div> Then I have some input checkboxes: <input class="regular" type="checkbox" /> <input class="bold" type="checkbox" /> <input class="italic" type="checkbox" /> So basically I have jQuery showing and hiding divs. Now I have another function that must iterate through these divs (one for each checkbox), and show

Jquery, hide & show list items after nth item

…衆ロ難τιáo~ 提交于 2019-11-27 07:36:26
Say I have an unordered list, like so: <ul> <li>One</li> <li>Two</li> <li>Three</li> <li>Four</li> <li>Five</li> </ul> How would I, using JQuery, hide the last 2 list items and have a 'show more' link there, so when clicked upon, the last 2 list items would appear? <ul> <li>One</li> <li>Two</li> <li>Three</li> <li style="display:none;">Four</li> <li style="display:none;">Five</li> <li>Show More</li> </ul> pex Try the following code example: $('ul li:gt(3)').hide(); $('.show_button').click(function() { $('ul li:gt(3)').show(); }); For fun, here's a roundabout way to do it in one chain: $('ul')