Search Results

Search found 4 results on 1 pages for 'katiek'.

Page 1/1 | 1 

  • jQuery - How to combine has() and gt()

    - by KatieK
    With jQuery 1.4.2, I can't figure out how to combine has() with :gt. I'd like to select any ul which contains more than 3 lis, so here's what I've tried: $(document).ready(function(){ $("ul.collapse:has(li:gt(2))") .each( function() { $(this).css("border", "solid red 1px"); }); }); This does work with the 1.2.6 jQuery library, but not 1.3.2 or 1.4.2. I'd appreciate any help in understanding what's going on here. Thanks!

    Read the article

  • Adding new elements into DOM using JavaScript (appendChild)

    - by KatieK
    I sometimes need to add elements (such as a new link and image) to an existing HTML page, but I only have access to a small portion of the page far from where I need to insert elements. I want to use DOM based JavaScript techniques, and I must avoid using document.write(). Thus far, I've been using something like this: // Create new image element var newImg = document.createElement("img"); newImg.src = "images/button.jpg"; newImg.height = "50"; newImg.width = "150"; newImg.alt = "Click Me"; // Create new link element var newLink = document.createElement("a"); newLink.href = "/dir/signup.html"; // Append new image into new link newLink.appendChild(newImg); // Append new link (with image) into its destination on the page document.getElementById("newLinkDestination").appendChild(newLink); Is there a more efficient way that I could use to accomplish the same thing? It all seems necessary, but I'd like to know if there's a better way I could be doing this. Thanks!

    Read the article

  • How do I select only the 4th and higher LIs in each UL?

    - by KatieK
    For this XHTML: <ul class="collapse"> <li>One</li> <li>Two</li> <li>Three</li> <li>Four</li> <li>Five</li> </ul> <ul class="collapse"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> Using jQuery, how do I select only the 4th and higher LIs in each UL? I've tried: $("ul.collapse li:gt(2)").css("color", "red"); But it selects the 4th and higher LIs in the whole document. "Four", "Five", and "1", "2", "3", "4" are red.

    Read the article

  • jQuery - Why doesn't combining has() and gt() work in some cases?

    - by KatieK
    I wanted to select any ul which contains more than 3 lis. This code worked with the 1.2.6 jQuery library: $("ul:has(li:gt(2))") .each( function() { $(this).css("border", "solid red 1px"); }); But not 1.3.2 or 1.4.2. This code worked with the 1.4.2 jQuery library: $('ul').has('li:nth-child(3)').css('border', 'solid red 1px'); But not v1.2.6. Why does each version work with one library version, but not the other? Am I encountering some kind of bug, or am I doing something wrong? Any help understanding , or differences to be aware of between different versions of the jQuery libraries, would be much appreciated. Thanks!

    Read the article

1