addclass

Add class and remove class based on checked radio? [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-13 06:27:39
问题 This question already has answers here : Add class to target based on radio input value (toggle, like function) (2 answers) Closed 6 years ago . Here is my jsbin, http://jsbin.com/ugufi/11 I removed any attempt I made to remove the class, because it just kept alerting undefined. My problem is when I add the checked class to my target I (as said above) fail to remove the class of the target. I cannot use parent or sibling selectors, because the target is separate from my nested radio inputs.

jQuery switching between more than two classes

让人想犯罪 __ 提交于 2019-12-13 03:03:55
问题 I've already posted a question about jQuery toggle method here But the problem is that even with the migrate plugin it does not work. I want to write a script that will switch between five classes (0 -> 1 -> 2 -> 3 -> 4 -> 5). Here is the part of the JS code I use: $('div.priority#priority'+id).on('click', function() { $(this).removeClass('priority').addClass('priority-low'); }); $('div.priority-low#priority'+id).on('click' ,function() { $(this).removeClass('priority-low').addClass('priority

addClass converting from jQuery to MooTools

China☆狼群 提交于 2019-12-13 02:25:40
问题 I have Kunena forum template for Joomla that use MooTools 1.4. I integrated in this theme bootstrap tooltip functionality and added MooTools addClass to trigger tooltips in some classes. I checked MooTools doc's and the code should looks like below: $$('h3 a, .tk-page-header h1 .tk-latestpost a, .tk-topic-title a, .tk-topic-info a, .tk-preview-avatar a, .tk-social-icons a, .kpost-user-icons a, .kicon-profile, .tk-user-info-body li a, span.kkarma-plus, span.kkarma-minus, .btnImage').addClass('

Add/Remove class onclick with JavaScript no librarys

China☆狼群 提交于 2019-12-12 19:14:16
问题 I am developing a mobile site and want to use JS for nothing more than adding and removing classes. So, in the interest of keeping things nice and light I don't want to use jQuery. I have the following HTML: <div id="masthead"> <a href="index.html" title="Home" id="brand">Brand</a> <a href="#" id="openPrimaryNav">Menu</a> <ul id="primaryNav" class=""> <li><a href="index.html" title="Home">Home</a></li> <li><a href="benefits.html" title="Benefits">Benefits</a></li> <li><a href="features.html"

addClass to getElementsByClassName array

不羁岁月 提交于 2019-12-12 15:07:12
问题 I need a little help as i am getting frustrated with .getElementsByClassName. I have an svg map that has paths with classes. I now need to list all with a certain class and add another class. Right now i have var testarray = (document).getElementsByClassName("currentclass"); for(var i = 0; i < testarray.length; i++) { testarray.item(i).className("classtobeadded"); } This returns me a "undefined is not a function" error. I've tried $(document), (document), (jQuery), i've tried $(".currentclass

CSS3 - add class to fire an animation and remove class on completion

人走茶凉 提交于 2019-12-12 12:02:35
问题 I have a div and when I click it jquery adds a class which starts an animation running. When the animation stops (after 3 seconds) I want the class to be removed, so that when the div is clicked on again the animation will start over. This is only testing and only Chrome browser at the moment. Here is my CSS3: .spin360 { -webkit-animation-name: spin; -webkit-animation-duration: 3s; -webkit-animation-iteration-count: 1; -webkit-animation-timing-function: ease; -webkit-animation-fill-mode:

jQuery addClass not working

半城伤御伤魂 提交于 2019-12-12 08:48:29
问题 I'm trying to use addClass to give me zebra-striped tables on my Joomla template. Im using the following code: <script> jQuery(function($) { $("tr:odd").addClass("odd"); }); </script> I've been able to use the tr:odd selector to add css to table rows dynamically, but when i use the addClass function it just doesnt (I checked the source code produced and none of the table rows have the class "odd"). Havn't a clue what I could be doing wrong, would appreciate any help. 回答1: So you know, changes

How to assign a class “active” to the li element based on current URL and click event using jQuery or JavaScript

一世执手 提交于 2019-12-11 19:05:01
问题 I am trying to create a menu where a class "active" is assigned to the page whenever it's selected and loaded. Right now it is applied only to the index page by default. My menu snippet: <ul class="nav navbar-nav"> <li class="active"><a href="http://localhost/wp/index.php">Main</a></li> <li><a href="http://localhost/wp/news">News</a></li> <li><a href="http://localhost/wp/contacts">Contacts</a></li> </ul> 回答1: Try this code. Its working at my end. <script> jQuery(document).ready(function() {

JQuery: add class to element - cannot use this class for selector?

只愿长相守 提交于 2019-12-11 18:18:07
问题 I have the following problem: in order to mark an element during different situation I want to add a class to the element: jQuery('#menu-item-41 a').addClass('newsbox-closed1'); Later I want to do some funny staff when the element with this class is clicked - so far it works fine: jQuery('.newsbox-closed1').click(function(){ jQuery('#newsbox').css('display', 'block'); jQuery(this).css('background-color', '#FF33AB').removeClass('newsbox-closed1').addClass('news-open'); }); Until now everything

Add class and insert before div

无人久伴 提交于 2019-12-11 13:58:48
问题 I would like to be able to add the class "wp" to each anchor tag that is before my "sub-menu dropdown-menu" class. How do I do this? My Current HTML: <a href="google.com">one</a> <ul class="sub-menu dropdown-menu"> <li id="menu-item-5"> <a href="">five</a> </li> </ul> <a href="google.com">one</a> <ul class="sub-menu dropdown-menu"> <li id="menu-item-5"> <a href="">five</a> </li> </ul> Desired Output <a href="google.com" class="wp">one</a> <a href="google.com" class="wp">one</a> 回答1: you can