toggleclass

Slidetoggle with a close button - jQuery

落爺英雄遲暮 提交于 2019-12-24 06:45:45
问题 I'm using the slidetoggle function to open & close a box when clicking on a link. I want to be able to add a "close" button (link) inside that box aswell as being able to close it via the slidetoggle trigger. How would i do this? This is my jQuery: $(".popup-b").hide(); $(".popup-l").click(function(){ $(this).toggleClass("active").next().slideToggle(0); return false; }); My HTML <a class="popup-l" href="#">Areas</a> <div id="area-p" class="popup-box"> <div class="close-this"><a href="#">Close

JQuery常用方法

此生再无相见时 提交于 2019-12-24 01:11:42
关于属性 Javascript: getAttribute setAttribute removeAttribute JQuery: attr removeAttr attr(传入属性名):获取属性的值 attr(属性名, 属性值):设置属性的值 attr(属性名,函数值):设置属性的函数值 attr(attributes):给指定元素设置多个属性值,即:{属性名一: “属性值一” , 属性名二: “属性值二” , … … } 关于内容 Javascript: innerHTML JQuery: html text .html() 不传入值,就是获取集合中第一个匹配元素的HTML内容 .html( htmlString ) 设置每一个匹配元素的html内容 .html( function(index, oldhtml) ) 用来返回设置HTML内容的一个函数 .html()方法内部使用的是DOM的innerHTML属性来处理的,所以在设置与获取上需要注意的一个最重要的问题,这个操作是针对整个HTML内容(不仅仅只是文本内容) .text() 得到匹配元素集合中每个元素的合并文本,包括他们的后代 .text( textString ) 用于设置匹配元素内容的文本 .text( function(index, text) ) 用来返回设置文本内容的一个函数 .text(

JQuery UI (effects core) addClass/removeClass on one element with multiple selectors…but there's a catch

浪子不回头ぞ 提交于 2019-12-23 16:27:31
问题 Thanks for taking a look. I'm trying to used the jQ UI addClass / remove Class methods to expand an hr element upon clicking preceding sibling divs. jQ UI effects core enables smooth animated transition between two classes: http://jqueryui.com/demos/removeClass/. Additionally, hr must be added dynamically with $ to achieve the broader site design. Here are the pieces of the puzzle: My code renders rows of four 100x100px sibling divs. These divs don't have classes, but FEEL FREE TO ADD THEM IF

difference between toggleclass and addclass

若如初见. 提交于 2019-12-21 09:09:03
问题 I am working with jquery and attempting to add a class to a table on the selection of that table row. I was initially using the following code - $(this).parents("tr").toggleClass("over", this.clicked); For some reason, that wasn't working in only some instances where there was already a class assigned. Before I went too crazy with any troubleshooting, I changed it to the following - $(this).parents("tr").addClass("over", this.clicked); This new option appears to be working fine. My question

Problems when toggling a class called “a:active” using jQuery

自作多情 提交于 2019-12-20 06:37:20
问题 As it stands, clicking on "Link" twice redirects you to a page, but whenever you click on and around it such that the menu drops down or goes up, the CSS code a:active span { color:#bdbcae; } is put into effect. What I am trying to do is make it so that the link only changes color when you click it the second time, resulting in you being redirected to the page. If you click it only once so that only the menu drops down, I want the link to remain its default color. This is the code in my

Three-way toggling of two states (Javascript or jQuery)

妖精的绣舞 提交于 2019-12-19 10:31:18
问题 I am working on a page that will show prices in a choice of currencies (euros, pounds or dollars). My aim is to display the price in euros first, keeping the pound and dollar prices hidden. <button id="mybutton">Change Currency</button> <p id="euro" class="shown">Euro</p> <p id="pound" class="hidden">Pound</p> <p id="dollar" class="hidden">Dollar</p> When the button is clicked, I need the three ids to cycle through the three states shown/hidden/hidden, hidden/shown/hidden and hidden/hidden

Javascript/HTML — Toggle Visibility (Automatically causing one div element to hide when another is rendered visible)

情到浓时终转凉″ 提交于 2019-12-18 02:49:10
问题 Essentially what I am trying to do is create a website that has all of its content on the home page but only has some of the content visible at any one time. The way I read to do this is through toggling visibility. The problem I am having is that: Assume the home page, when you first visit the website is blank (the way I want it to be). Lets say you click on the "about us" link. All of a sudden the about us section becomes visible (the way I want it to be). Now the problem that I have come

How to toggle between two divs

自古美人都是妖i 提交于 2019-12-17 19:25:42
问题 I am trying to toggle between two divs. For example, onload, I want the left content to show and the right content will remain hidden. If I click the right div, I want the left content to hide and the right content to appear and vise versa. I am very new to javascript but here is what I have. I can't seem to get it to work. Please help... Here is my HTML code: <div onclick="toggle_visibility('left');"> Left </div> <div onclick="toggle_visibility('right');"> Right </div> <div id="left" style=

jQuery基础笔记(2)

删除回忆录丶 提交于 2019-12-17 01:23:08
day54 筛选器 参考: https://www.cnblogs.com/liwenzhou/p/8178806.html#autoid-1-7-5 筛选器方法 下一个元素: $("#id").next() $("#id").nextAll() $("#id").nextUntil("#i2") 上一个元素: $("#id").prev() $("#id").prevAll() $("#id").prevUntil("#i2") 举例: <ul> <li id="l0">l0</li> <li>l1</li> <li>l2</li> <li id="l3">l3</li> <li>l4</li> <li>l5</li> </ul> 实践: 父亲元素: $("#id").parent() $("#id").parents() // 查找当前元素的所有的父辈元素$("#id").parentsUntil() // 查找当前元素的所有的父辈元素,直到遇到匹配的那个元素为止。 找父标签 <!--父标签--> <div id="d1">div-1 <div id="d2">div-2 <div id="d3">div-3 <a href="">a标签</a> </div> </div> </div> 实践: parents()、parentsUntil()作用看注释可知。 儿子和兄弟元素:

Font-Awesome icon won't change onclick

时间秒杀一切 提交于 2019-12-13 10:24:33
问题 This is so simple, but I can't get it to work! On clicking a button, I'd like to change the icon in that button from fa-download to fa-spinner, but the fa-spinner just won't show up! My HTML is: <button id='save'><i class='fa fa-download' aria-hidden='true'></i> save work</button> And my jQuery is: $('body').on('click', '#save', function(e){ $('#save').find('i').toggleClass('fa-download fa-spinner'); $("#save").text("loading..."); }); The text changes to loading, the download icon goes away,