addclass

Add fade-in or fade-out on the addclass / removeclass event

ⅰ亾dé卋堺 提交于 2019-12-08 04:02:41
问题 I am a beginner, please don't be to rough with me. I created an addclass and removeclass event : $(".myclass").click(function(){ $(".hiding").removeClass("hiding"); $(this).addClass("hiding"); }); This is the CSS : #wrapper a.hiding { display: none; } And the HTML : <div id="wrapper"> <a class="myclass" href="#2"> <img src=""> </a> </div> So for the moment, it works fine, but I would like to add a fade-in action when addclass, and fade-out when removeclass I tried by the CSS using -webkit

jQuery onclick addclass/removeclass and add fade

为君一笑 提交于 2019-12-07 16:57:46
问题 The past three day I have been searching for a solution to my problem. I have seen a lot of people with the same question as I have, but not one solution fixes my problem. So I am again where I started and I am asking for the help of you friendly people! I now have the following script running that works perfect for me: $(".show_commentsandnotes_container").click(function () { $('.commentsandnotes_bg').addClass('show'); $('.commentsandnotes_container').addClass('show'); }); $("

jquery addClass and removeClass with setInterval

戏子无情 提交于 2019-12-07 07:25:45
问题 I want to change class name every 3 seconds. Bu it doesn't work. How can I do this? $(document).ready(function() { function moveClass(){ var x = $('.liveEvents'); x.removeClass('liveEvents'); x.addClass('liveEventsActive'); x.removeClass('liveEventsActive'); x.addClass('liveEvents'); } setInterval(moveClass, 3000); return false; }); 回答1: You can do this in one line. Use toggleClass: setInterval(function(){$('.liveEvents').toggleClass('liveEventsActive')}, 3000); If you do your CSS correctly,

jQuery: after adding class to a new element, can't trigger event by clicking on that class

假装没事ソ 提交于 2019-12-06 17:09:30
问题 Here's what I'm attempting: when I click on an element with the class .main, that class is reassigned to the next element. When the next element (the new .main element) is clicked on, .main is reassigned to the next element, and so on. Here's my code: $('.main').click(function() { $(this).removeClass("main").addClass("other"); $(this).next().removeClass("other").addClass("main"); }); When I click on the original .main element, the class is transferred. However, clicking on the new .main

Add fade-in or fade-out on the addclass / removeclass event

感情迁移 提交于 2019-12-06 16:20:13
I am a beginner, please don't be to rough with me. I created an addclass and removeclass event : $(".myclass").click(function(){ $(".hiding").removeClass("hiding"); $(this).addClass("hiding"); }); This is the CSS : #wrapper a.hiding { display: none; } And the HTML : <div id="wrapper"> <a class="myclass" href="#2"> <img src=""> </a> </div> So for the moment, it works fine, but I would like to add a fade-in action when addclass, and fade-out when removeclass I tried by the CSS using -webkit-transition: all 0.5s ease; But it's not working. I recommend you try this edit: I realized just now using

OpenLayers: Adding a (css-)class to a marker?

浪尽此生 提交于 2019-12-06 12:07:54
G'day! I'd like to add a unique (css-)class to every single marker on my OpenLayers map, but i don't know how! I tried pretty much everything and also posted this question at the forums of OpenStreetMap (as the guys over there are pretty familiar with OpenLayers). This is the function i wrote to add markers: function ownMarker(lon,lat,icon,markerid) { var size = new OpenLayers.Size(38,58); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var element = new OpenLayers.Element.addClass('div', 'test'); var icon = new OpenLayers.Icon('images/marker/'+ icon +'.png', size, offset); var marker

How to use .removeClass() to disable jquery function

本秂侑毒 提交于 2019-12-06 12:03:51
I want the button click to remove the class "hover-on" so that the hover function becomes disabled, but once the DOM loads it removes the class, but the hover function still works. I am using the following code. //Click this $('button').click(function() { $('#main-div').removeClass('hover-on'); }); //Remove class to disable this hover function $('.hover-on').hover(function() { blah blah blah }); The event doesn't have anything with the CSS class. You need to unbind the event: $('button').click(function() { $('#main-div').removeClass('hover-on').unbind("hover"); }); $('.hover-on').hover

If hasClass then addClass to parent

≡放荡痞女 提交于 2019-12-06 01:39:38
问题 Original post: Why doesn't this simple script work? if ($('#navigation > ul > li > ul > li > a').hasClass('.active')) { $(this).parent().parent().parent().addClass(".active"); } EDIT: This won't hide the H1: if ($('#content h1').hasClass('aktiv')) { $(this).hide(); } Only this will: if ($('#content h1').hasClass('aktiv')) { $('#content h1').hide(); } Why can't I use the (this)? 回答1: The dot is not part of the class name. It's only used in CSS/jQuery selector notation. Try this instead: if ($(

JQuery adding class to cloned element

回眸只為那壹抹淺笑 提交于 2019-12-05 23:15:19
问题 This is my script: $('.addprop').click(function() { $('#clone').clone().insertAfter('.addprop'); }) I need to add a class to the new element that is being created. Is it possible? 回答1: Yes, it is: $('.addprop').click(function() { $('#clone').clone().addClass('newClass').insertAfter('.addprop'); }) Although you're cloning an element based on its id , $('#clone') , so note that there will be two elements sharing the same id , which makes the result invalid HTML, so I'd suggest: $('.addprop')

jquery addClass and removeClass with setInterval

守給你的承諾、 提交于 2019-12-05 14:23:13
I want to change class name every 3 seconds. Bu it doesn't work. How can I do this? $(document).ready(function() { function moveClass(){ var x = $('.liveEvents'); x.removeClass('liveEvents'); x.addClass('liveEventsActive'); x.removeClass('liveEventsActive'); x.addClass('liveEvents'); } setInterval(moveClass, 3000); return false; }); You can do this in one line. Use toggleClass : setInterval(function(){$('.liveEvents').toggleClass('liveEventsActive')}, 3000); If you do your CSS correctly, you don't need to remove the liveEvents class. Just make the liveEventsActive class overwrite what you need