removeclass

.parents().removeClass() not working

ⅰ亾dé卋堺 提交于 2019-12-06 10:33:28
i got this javascript, trying to remove a class on a parent element: $(this).parents(".box").removeClass("expanded"); on this html: <div class="box trx"> <a href="javascript:;" class="open-content"><?php the_post_thumbnail('thumbnail'); ?></a> <div class="expandable"> <?php the_content(); ?> <span class="simple"> <a class="cunload" href="javascript:;">Close</a> </span> </div> </div> Unfortunately, this doesn't work so far. I've done several tests like: $(this).parents(".box").removeClass("trx"); and $(this).parents(".box").addClass("exd"); It all works. I'm using jQuery 1.6.2 and jQuery

Delete all classes after a certain class

自闭症网瘾萝莉.ら 提交于 2019-12-05 22:41:08
I have a < div id="thisdiv" class="class1 class2 class3 class4 class5"> text < /div> I need to be able to delete all classes after class3 with jQuery. something like $('#thisdiv').removeClass(all after class3); OR $('#thisdiv').attr('class', all from class1 to class3); Please how can I do that? You can try the following, but your classes might not be in the same order as they appear in the HTML source: $('#thisdiv').attr('class', function(i, v) { var classes = v.split(' '), position = $.inArray('class3', classes); return classes.slice(0, position + 1).join(' '); }); Here's the fiddle: http:/

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

Remove multiple classes at once

对着背影说爱祢 提交于 2019-12-04 07:23:51
问题 I have the following html <div class="row"> <div class="one someclass"></div> <div class="two someclass"></div> <div class="three someclass"></div> </div> <div class="row"> <div class="one someclass"></div> <div class="two someclass"></div> <div class="three someclass"></div> </div> And I want remove all one, two, three attribute I tried $(function () { $('div').removeAttr('one', 'two', 'three'); }); but didn't work. I think this is wrong method. What should I do? 回答1: removeClass accepts a

JQuery Find #ID, RemoveClass and AddClass

狂风中的少年 提交于 2019-12-04 00:02:18
I have the following HTML <div id="testID" class="test1"> <img id="testID2" class="test2" alt="" src="some-image.gif" /> </div> I basically want to get to #testID2 and replace .test2 class with .test3 class ? I tried jQuery('#testID2').find('.test2').replaceWith('.test3'); But this doesn't appear to work ? Any ideas ? jQuery('#testID2').find('.test2').replaceWith('.test3'); Semantically, you are selecting the element with the ID testID2 , then you are looking for any descendent elements with the class test2 (does not exist) and then you are replacing that element with another element (elements

Function work after second click

此生再无相见时 提交于 2019-12-03 00:42:00
问题 Anyboby help. Why function add class active this.parents(".block-parent").find(".periods[data-period="+typelink+"]").addClass('active') work after second click? need to be done after first click! link for not right example http://jsfiddle.net/kngU8/ Page.contentSort = function() { var $eachblocks = $(".top10_month .periods"); var $blockhead = $(".block-head__link"); $blockhead.on("click", function(e){ var $this = $(this); var typelink = $(".block-head__link.active").attr("data-date"); e

Function work after second click

泄露秘密 提交于 2019-12-02 14:31:40
Anyboby help. Why function add class active this.parents(".block-parent").find(".periods[data-period="+typelink+"]").addClass('active') work after second click? need to be done after first click! link for not right example http://jsfiddle.net/kngU8/ Page.contentSort = function() { var $eachblocks = $(".top10_month .periods"); var $blockhead = $(".block-head__link"); $blockhead.on("click", function(e){ var $this = $(this); var typelink = $(".block-head__link.active").attr("data-date"); e.preventDefault(); $this.parents("ul").find("a").removeClass("active"); this.className += " active"; $this

Remove multiple classes at once

不问归期 提交于 2019-12-02 12:59:13
I have the following html <div class="row"> <div class="one someclass"></div> <div class="two someclass"></div> <div class="three someclass"></div> </div> <div class="row"> <div class="one someclass"></div> <div class="two someclass"></div> <div class="three someclass"></div> </div> And I want remove all one, two, three attribute I tried $(function () { $('div').removeAttr('one', 'two', 'three'); }); but didn't work. I think this is wrong method. What should I do? removeClass accepts a space-delimited list of the class names to remove, so: $("div.one, div.two, div.three").removeClass("one two

Add and Remove class to click a dynamic Button

蓝咒 提交于 2019-12-02 08:56:19
Trying to Add and Remove class to click dynamic Buttons, means this button <button class="one"></button> get class dynamically like this: <button class="one text1">text1</button> So if button one has class .text1 and by click this add class .hide to list item <li class="text1"> like <li class="text1 show"> Same for button two <button class="two"></button> and by click add class <li class="text2 show"> Note: when click button two , then should remove class .show and add new class .hide to button one . Main HTML: <div id="main-id"> <button class="one"></button> <button class="two"></button> <ul>

How to delete a element by tag name with all elements inside it

孤者浪人 提交于 2019-12-02 08:33:33
I want to use the dom removeChild function in php to remove everything between a tag. my xml looks like <root> <element>text</element> <remove> text <morexml>text</morexml> </remove> </root> Now I want to remove the tag including its entire inside. How do I do this? I do not have a clue. I am trying to use the only dom function i found: removeChild. When removed it has to look like this: <root> <element>text</element> </root> Is there a php dom function to do this? I can not find it on google or stackoverflow. $dom = new DOMDocument; $dom->loadXML($xml); $dom->getElementsByTagName('root')-