addclass

jQuery and Prototype Selector Madness

Both the jQuery and Prototpye JavaScript libraries refuse to allow me to use a variable to select an list item element by index number although they accept a hard coded number. For example, in Prototype this works: $$('li')[5].addClassName('active'); But this will not work no matter how I try to cast the variable as a number or inte...

JQuery : adding 5 id's on the fly (instead of classes)

Hello guys, I'm dealing with this situation : I have a color animation script which targets by id (it's not JQuery but pure javascript) then I have a dynamic list without ids : 'ul' somePHP throwing list items '/ul' and finally I have JQuery itself (which I'll use to add several ids on the fly to the list items: but I still don't know...

jQuery addClass question

I want to add a class to multiple span elements with common classname's based on the classname of a link that is being clicked. This works for me only for the first element (1). The rest gives no result (also no error). Here is the code I'm trying to get functional, first HTML then the jQuery part: <ul id="brancheNav"> <li><a href="...

jQuery addClass not working

Hi, 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 chec...

IE6 performance issues with adding className on multiple elements (jQuery tableHover plugin)

In an application I write that uses a large HTML table of numbers the design requires that the row and column of the hovered cell will be highlighted. I develop all the JS for this project using jQuery 1.3.x, and I found the tableHover plugin that does exactly what I need. But: on IE6 the performance of this plugin drops down as the n...

Removing active class and adding it to a sibling

Currently, I have a jQuery Cycle plugin that allows the image to scroll. With it's callback I am calling this function function onAfterVideoScroll() { $('.myRemote.active').removeClass("active").next().addClass("active"); } This SHOULD be removing the current class from another set of links, and adding the class to the it's next sib...

jquery addclass styling doesn't work, wrong selector?

<li id="leistungen"><a href="#Leistungen" onclick="sitemapChangeSubMenu('leistungen','leistungencontent','leistungen'); return false;">LEISTUNGEN</a> </li> This is the list-item which I want to style with: $("#leistungen a").addClass("brown"); This doesn't work for either: $("#leistungen").addClass("brown"); my css code is just ...

Remove second class from an element and add another class

Hi, $(document).ready ( function () { $(".MenuItem").mouseover ( function () { // Remove second class and add another class [ Maintain MenuItem class ] // Eg: For div1 remove Sprite1 and then add Sprite1Dis and for div2 // remove Sprite2 and add Spprite2Dis }); $(".MenuItem").mouseout ( function () ...

addclass to first-level elements only

HTML: <table id="table-1"> <tr> <td> <table> <tr> <td>content</td> <tr> </table> </td> <td>Content</td> </tr> </table> Is it possible to addclass 'td-1' to ONLY first-level TD's of #table-1 and not all? Thanks ...

addID in jQuery?

Is there any selector available to add IDs like there is for adding a class - addClass()? ...

Find text in element and addClass to Parent

HTML: <table> <tr> <td> <a href="#" class="nav">link</a> <td> </tr> </table> I want to: FIND TEXT 'link' in a.nav and ADD ID "abc" to 'table'. Tried this but it doesn't work: $('table>tbody>tr>td>a.nav:contains("Forum Index")').parents('table').attr('id', 'newID'); (tbody because most browsers add it automatically) ...

addClass using .live() with jQuery

I am currently using the .load() function to load content into a container div dynamically. The content being loaded is table data which I'd like to zebra stripe. The zebra striping is easy on a static page, but I can't figure out how to zebra stripe the new content loaded into the container div. Here's the code with which I'm trying ...

JQuery keeping addClass stored after page reload

Hello, I am pretty new to JQuery and I'm working on a menu based on Superfish script. I am having troubles to keep the addClass on current clicked item set when I navigate thru links. My code: JS <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function(){ jQuery("ul.sf-menu").superfish({pathClass: 'corren...

addClass to Parent

HTML: <div class="tabbed-section"> <ul class="tabs"> <li><a href="#tab-1">Tab 1</a><li> <li><a href="#tab-2">Tab 2</a><li> </ul> <div id="tab-1" class="panel"> content 1 </div> <div id="tab-2" class="panel"> content 2 </div> </div> jQuery: $('.tabbed-section .panel').hide();...

Dynamic Class names (jQuery)

<label>Hatchback <input type="checkbox" name="" /></label> <label>Bike <input type="checkbox" name="" /></label> <label>Sedan <input type="checkbox" name="" /></label> <label>Scooter <input type="checkbox" name="" /></label> <label>Coupe <input type="checkbox" name="" /></label> <label>SUV <input type="checkbox" name="" /...

CSS has no effect on dynamic classes

$('fieldset.one label, fieldset.two label').each(function () { var className = $(this).text().trim().toLowerCase(); $(this).addClass('default ' + className); }); I'm adding classes dynamically to label elements, but when I try to style them, there is no effect. One of them has .sedan class added automatically, I see it in fireb...

addClass on condition

HTML: <ul id="list"> <li>item</li> <li>item</li> <li>item</li> <li>item</li> <li class="action">item</li> </ul> jQuery: $("#list li:last").addClass("active"); This almost works, but the "action" item takes the "active" class when its present which I don't want. How do I rewrite the above jQuery so it always ignores the li...

jQuery adding and removing 'active' classes plus hover

I have a definition list with thumbnails. They are 50% opacity with a 'thumb' class. When hovered 100% opacity. When clicked 100% opacity plus change 'thumb' to 'thumbactive' class So far my crappy code works, only thing is I can not get the tn on 100% on click. dl { width: 700px; } dt { clear: left; float: right; widt...

Changing background color of table rows based on click event with jquery

When the document is ready to be manipulated, jquery adds a class to every even row, and another to every odd row, in order to visually see the different rows. But whenever I update (sort based on header) the rows, they don't update no matter what i try. <script type="text/javascript"> $(document).ready( function( ) { $('table ...

jquery addClass not working on tablecell

Hi, I need some help with this I am trying to do this if(perc>0){ alert('change backgroundcolor and textcolor'); $('#stocktable tr td:last').addClass('stockhigher'); } but It does not work on a tablecell I also try'd to set the selector like this $('#stocktable tr td:eq(2)).addClass... $('#stocktable tr td.percentage').addClass...