addclass

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

How can I change the color of a changed cell in Handsontable?

馋奶兔 提交于 2019-12-20 05:23:22
问题 I am using the Handsontable plugin and when the user changes the values in the cell, it should turn yellow so they can keep track of what has been changed. In this case, yellow is class .changeInput. The tricky part is when you double click the cell to change it, this becomes a textarea and no longer a td. Any ideas? Thanks in advance. http://jsfiddle.net/PAH5J/ jQuery $("textarea.handsontableInput").change(function (){ //$(this).find(td).addClass('changeInput'); $('.htNumeric .current')

if checkbox checked add class to parent element

纵饮孤独 提交于 2019-12-19 08:12:44
问题 I have a table with checkboxes looking like this: <td class="table-col" > <div class="group-one" > <input type="checkbox" /> </div> </td> What I want to do is when the checkbox is checked to apply a "selected" class to "table-col". if ($('.table-col').find(':checked')) { $(this).parent().parent().addClass('selected'); } I looked at many post with a similar solution like above but it doesn't seem work for me. I'm not sure why but this is pointing to HTMLDocument not the element. (edit) On this

if checkbox checked add class to parent element

主宰稳场 提交于 2019-12-19 08:12:24
问题 I have a table with checkboxes looking like this: <td class="table-col" > <div class="group-one" > <input type="checkbox" /> </div> </td> What I want to do is when the checkbox is checked to apply a "selected" class to "table-col". if ($('.table-col').find(':checked')) { $(this).parent().parent().addClass('selected'); } I looked at many post with a similar solution like above but it doesn't seem work for me. I'm not sure why but this is pointing to HTMLDocument not the element. (edit) On this

Rework jQuery Scripts to Utilize Wildcard Targeting of Classes/Ids

北慕城南 提交于 2019-12-18 09:42:04
问题 I currently have a (fairly sizable) JavaScript file which is used to animate some elements on a page. There are four 'sets' of scripts used on the page, each set contains a number of scripts equal to the number of steps in the tutorial on the page. What I would like to do is rework the scripts so that they will use wildcard targeting (if possible) instead of using the current setup (which is one script per function per step). I will provide the first script from each of the sets: First

Add & remove active class from a navigation link

江枫思渺然 提交于 2019-12-18 05:04:16
问题 I have been looking for tutorials on how to add and remove a class from a link unfortunately without any success. All the earlier questions on this have give me some understanding, but haven't give me the result I want to accomplish. I'm trying to have an active state for my navigation, by adding and removing a class when the link is clicked. Here is what I have as far as JavaScript: $(document).ready(function(){ //active state $(function() { $('li a').click(function(e) { e.preventDefault();

Remove all classes except one

早过忘川 提交于 2019-12-17 17:54:15
问题 Well, I know that with some jQuery actions, we can add a lot of classes to a particular div: <div class="cleanstate"></div> Let's say that with some clicks and other things, the div gets a lot of classes <div class="cleanstate bgred paddingleft allcaptions ..."></div> So, how I can remove all the classes except one? The only idea I have come up is with this: $('#container div.cleanstate').removeClass().addClass('cleanstate'); While removeClass() kills all the classes, the div get screwed up,

Can I put delay(500) before an addClass()?

匆匆过客 提交于 2019-12-17 15:36:47
问题 $(document).ready(function(){ $("#info-text-container").click(function(){ $("#info-text").delay(500).addClass("info-text-active"); }); }); This does not put an delay on it when it gets clicked. Which I want to accomplish. Why and is this hackable, possible to overcome? Thanks! 回答1: delay only works with animating methods, you can use setTimeout function: $("#info-text-container").click(function(){ setTimeout(function(){ $("#info-text").addClass("info-text-active"); }, 500); }); 回答2: Not quite

Add Class to <body> if a DIV has more then 4 elements

做~自己de王妃 提交于 2019-12-14 03:34:19
问题 I'm trying to add class to <body> when <div class="scroll"> has more then 4 <li>text</li> elements. HTML: <body> <div class="scroll"> <div> <!-- Parent Element --> <ul> <!-- Parent Element 2 --> <li>text</li> <!-- Child 1--> <li>text</li> <!-- Child 2--> <li>text</li> <!-- Child 3--> <li>text</li> <!-- Child 4--> <li>text</li> <!-- Child 5--> </ul> </div> </div> <body> Means if <div class="scroll"> has 5 <li>text</li> item then add class to body like <body class"popup"> . Any body know how to

addClass to body won't work

試著忘記壹切 提交于 2019-12-13 23:27:34
问题 I'm trying to make my background change during the day depending on the time, tried 4 different methods and searched here, but still can't figure it out. Can anybody tell me what i'm doing wrong? Thanks in advance! $(document).ready(function(){ var d = new Date(); var n = d.getHours(); if (n > 6 || n < 10) $(body).addClass('two'); else if (n > 10 && n < 17) $(body).addClass('one'); else if (n > 17 && n <= 19) $(body).addClass('three'); else $(body).addClass('five'); }); CSS .one{ background