jQuery plugin to add a CSS class to last-child DOM elements

This has been bugging me for ages. IE < 9 does not support the CSS3 last-child pseudo class. I’ve created a _very_ simple jQuery plugin to add a CSS class “last-child” to the element that is the last child of a DOM element.

It performs this recursively, so it’ll apply the class to the last child of an element as well as to the last child of all it’s children…and so on and so forth.

It’ll perform this on each of the set of matched elements in a jQuery object. So you can have it traverse the whole, of your page by providing a jQuery object with the <body> element in it, or you can pick and choose DOM elements to apply the plugin to for efficiency. For instance, you might only need the "last-child" class to be applied to the last child of an unordered or ordered list:

    $('body').lastChild(); // Applies to all elements attached to the document.body
    $('ul, ol').lastChild(); // Applies to all elements in an unordered or ordered list

By default, the plugin applies the CSS class to a restricted set of DOM element types. You can specify the types of DOM elements to apply the class to by passing an options object to the function. In this way you can also specify the name of the CSS class that will be applied:

    $('ul, ol').lastChild({
        tags:['li'], // Only elements with the tag name 'li' will have the class applied to them
        cssClass:'ie-last-child' // The CSS class name will be 'ie-last-child'
    });

For super shorthand, you can simply pass a string to the lastChild function – which it presumes to be the CSS class you want to use:

    $('ul, ol').lastChild('ie-last-child');

You can download the plugin here.

Note, while I created this plugin to get around my IE problem, it is not built specifically for IE. If you only want IE to receive these classes, you’ll probably want to do something like:

    if($.browser.msie) {
        $('body').lastChild();
    }

…but obviously preferably using Modernizr:

    if($('.ie6, .ie7, .ie8').length) {
        $('body').lastChild();
    }

Enjoy!

37 thoughts on “jQuery plugin to add a CSS class to last-child DOM elements

  1. Women who took part in a supervised exercise program during adjuvant treatment for breast cancer had better cardiovascular function than women who did not participate in the program buy priligy reddit If you don t have PCOS then either medication should be okay

  2. Der South Park Slot besitzt viele spezielle Funktionen und Bonusspiele.

    Während der Freispiele darf man sich für eines der vier Häuser entscheiden, die unterschiedliche
    Eigenschaften haben. Diese sind meist simpler und bieten weniger Funktionen,
    haben aber für viele Spieler einen hohen Nostalgiefaktor.
    Mit Hilfe der Bonussymbole könnt ihr zehn Freispiele aktivieren. Aber
    hier warten Freispiele und die Jagd nach einem atemberaubenden Schatz.
    Im Inneren der Muschel befinden sich hübsche Perlen und 15 Freispiele.

    Ich habe neben der Seriosität auch die Möglichkeit geprüft, unterwegs auf dem Mobilgerät zu spielen. In meinen Erfahrungsbericht kannst du
    alles Wichtige über den Anbieter von virtuellen Automatenspielen herausfinden. Wenn Sie Zugang zum
    ‘Großen Spiel’ haben möchten, also an den Roulette, Poker oder Blackjack Tischen spielen möchten, müssen Sie in der Regel mit 2 bis 5 Euro Eintritt rechnen. So wird
    sichergestellt, dass kein süchtiger Spieler, der sich freiwillig für Casinos im jeweiligen Bundesland gesperrt hat, und kein Falschspieler oder aggressiver Zocker in das Casino gelangt.

    Sie bieten transparente Bonusbedingungen und gewährleisten eine sichere Zahlungsabwicklung mit schnellen Auszahlungen.
    Legale Online Spielbanken sind lizenziert und unterliegen strengen Regulierungen, die den Spielerschutz, sichere Auszahlungen und
    Datenschutz sicherstellen. Grundsätzlich sollte man zunächst erstmal nur Online Spielotheken nutzen, die mit der offiziellen deutschen Glücksspiellizenz
    ausgestattet sind. Setze dir zunächst ein klares Budget und spiele verantwortungsbewusst, um Verluste zu begrenzen. In Deutschland unterliegen lizenzierte Anbieter strengen Vorgaben, die auch den Support betreffen.

    References:
    https://online-spielhallen.de/avantgarde-casino-mobile-app-dein-mobiles-spielerlebnis/

  3. Falls du sowohl Freispiele als auch Bonusguthaben hast, beginne immer mit den 50 Free Spins.

    Für den Umsatz zählen vor allem Slots ( %), Tischspiele meist nur anteilig.
    Diese Freispiele gelten für Top-Slots wie Book of Dead
    oder Starburst. Bereits zur Anmeldung erhalten Spieler einen Verde Casino Bonus Code 25 Euro ohne eigene Einzahlung.
    Der Verde Casino Bonus ist speziell auf deutsche Spieler zugeschnitten und bietet vielfältige Vorteile.
    Das spektakuläre Willkommenspaket von bis zu €1200 plus 220
    Freispiele verteilt auf vier Einzahlungen macht den Einstieg besonders attraktiv.

    Die Verde Casino 50 Freispiele werden Ihnen also vollkommen kostenfrei gutgeschrieben. Nachdem
    Sie die Casino Verde Freispiele aktiviert haben, müssen einige Bedingungen erfüllt werden, bevor Sie die Auszahlung in Form von echtem Geld beantragen können. Überwachen Sie Ihr
    Spielverhalten und achten Sie auf Anzeichen von problematischem Glücksspiel.
    Das Spielangebot ist umfangreich und enthält Slots mit diversen Funktionen, aber auch Live Casino
    Games, Insta-Spiele, Bingo, die bekanntesten Tischspiele und ein Wettangebot.

    Als moderne Alternative zu klassischen Slots bietet das
    Verde Casino einen Bereich mit sogenannten „Insta Games“.
    Das Live Casino ist das Kronjuwel des Verde Casinos und bietet
    ein erstklassiges, authentisches Spielerlebnis.
    Wenn Sie beispielsweise planen, insgesamt 400€ einzuzahlen, könnten Sie diese auf die
    vier Stufen verteilen (z.B. 100€, 100€, 100€, 100€), um den maximalen Bonus von 1.200€ zu
    erhalten.

    References:
    https://online-spielhallen.de/casino-bregenz-auszahlung-ihr-umfassender-leitfaden/

  4. Die Kernaufgabe unserer Seite ist es Ihnen eine schnelle und zuverlässige Übersicht
    über Deutsche online Casinos, also über Casinos, die Deutsche
    Spieler akzeptieren, zu geben. Je nach Lizenz
    haben Casinos jedoch unterschiedliche Eigenschaften und Features, wie
    zum Beispiel Einsatzlimits oder Spielauswahl. Daher muss jedes online Casino in Deutschland 2025 über eine sichere Lizenz verfügen.
    Die Zahlungsmethoden in deutschen Online Casinos und Spielotheken sind vielfältig,
    sicher und schnell. Aufgrund der deutschen Glücksspielregulierung
    gibt es aktuell nur das Online Casino der Spielbanken-Bayern.
    Dabei schauen wir uns nicht nur die Sicherheit und die Casino Boni an, sondern werfen auch einen Blick auf die Auswahl
    an Casinospielen, die Zahlungsmethoden und auch den Kundendienst.

    Sämtliche Gewinne aus den Freispielen können sofort und ohne Begrenzung
    zur Auszahlung beantragt werden. Generell ist es
    empfehlenswert, dass Sie nur auf Spiele Webseiten spielen,
    welche von unseren Casino Experten auf Herz und Nieren getestet wurden. Solche neuen Online Casinos zum
    Spielen von Glücksspielen sind aber meistens noch
    nicht sehr bekannt und deswegen ist es immer etwas Risiko, auf diesen Webseiten zu spielen. Wenn Sie eine
    bestimmte Art des Glücksspiels bevorzugen, kann Ihnen die folgende Tabelle helfen, das beste legale Online Casino in Österreich zu finden.

    References:
    https://online-spielhallen.de/casino-of-gold-freispiele-ihr-weg-zu-kostenlosen-spielrunden/

  5. The unattended remote access capability allows IT staff to perform
    maintenance, updates, and troubleshooting
    without requiring end-user participation. The robust administration console provides complete connection visibility to maintain security protocols while delivering detailed support analytics.
    TeamViewer’s lightweight application performs even on limited bandwidth connections,
    making it ideal for digital professionals who frequently find
    themselves using hotel WiFi or mobile devices’ hotspots.
    The personal use version offers robust security features that protect
    your sensitive data while maintaining the ease of use that makes TeamViewer so popular among non-technical
    users. And with the full-featured TeamViewer Remote
    web app, you can access all your devices from any browser.

    TeamViewer stands out for its secure, reliable remote access connections across multiple devices.
    It’s a lightweight, executable program that
    requires no installation, enabling end-users to temporarily grant access to their devices for attended access and remote support.
    This includes connecting between your personal devices or helping
    friends and family with remote support. Remote access software
    uses an internet connection to establish a secure link between two
    remote computers, allowing users to control the
    remote computers as if they were physically present.
    Maintenance teams gain secure remote access to troubleshoot equipment, run diagnostics, and
    deploy updates remotely—particularly valuable for hazardous or remote locations.

    With TeamViewer’s remote access capabilities, you don’t need a VPN
    to connect. Our platform ensures seamless cross-device unattended remote access, so you’re
    never tied to one location. “Trusting a remote access solution that can do just this might seem simple, but finding the right partner is easier said than done. From Hamburg to Namibia—with TeamViewer, the Steps for Children team can ensure all devices and systems are up to date and operational, helping volunteers focus on the tasks that matter most. With TeamViewer Remote, you can securely connect to your IT systems from any location to provide seamless support in an instant. With TeamViewer, simply install the application on both devices, start the program, and enter the ID and password of the remote device you want to connect to.

    References:
    https://blackcoin.co/win-up-to-1000-200-free-spins-at-winshark-casino/

  6. Consequently, the decision made by the casino was upheld, and the complaint was
    formally rejected. Despite providing extensive proof-of-funds documentation, the casino
    only cites vague terms without any specific evidence or resolution. We find customer support important,
    since its purpose is to help you resolve any issues you might experience, such as registration at RocketPlay
    Casino, account management, withdrawal process, etc.
    It’s like afree test drive with real stakes – what’s
    not to love about that?! This thoughtful nod to local preferences justmakes the whole experience smoother, more intuitive, and way moreaccessible.

    One of the biggest, most underrated wins for us Down Under
    is theglorious ability to play in our very own Australian Dollars (AUD).Sounds like a small detail, right?

    When you first land on the RocketPlay casino Australia homepage,
    you’renot just greeted with a generic layout; you’re welcomed into a sleek,modern,
    and intuitively designed space. Get ready todiscover
    why so many Aussies are already calling this their go-to spotto Play & Win Big – because
    at casino Rocket Play, every moment ispacked with potential!
    Seriously, the moment you land at RocketPlay casino,you’ll
    feel like you’ve discovered a hidden gem in the vast digitalcosmos.

    RocketPlay maintains the highest security standards, utilizing advanced SSL encryption to protect all player data and financial transactions.

    We support traditional banking methods alongside modern cryptocurrency options, providing flexibility for every player preference.
    Regular tournaments provide additional winning opportunities beyond standard gameplay.

    Members enjoy higher withdrawal limits, dedicated account managers,
    exclusive bonuses, and invitation-only tournaments.
    Free spins are integrated throughout our bonus structure, from first
    deposit rewards to ongoing promotional campaigns.
    These classic offerings maintain the strategic depth and excitement of their land-based counterparts while providing the convenience and accessibility of online gambling.

    References:
    https://blackcoin.co/expert-guide-to-online-gambling/

  7. Secure payment methods are vital in online gambling to protect players’ financial
    information and maintain trust in online casinos.

    Many Australian online casinos offer a variety of high RTP games, making them attractive due to better winning
    chances. For 2025, players should focus on casinos highlighting bonuses, diverse games, and high payout rates.

    The leading Australian online casinos distinguish themselves with extensive game selections, appealing bonuses, and dependable
    payment methods.
    If you’re playing at an online casino in Australia for real money, a
    reload can give your balance a bit of extra kick. The first, and usually the biggest, bonus
    you’ll get when signing up to new online casinos in Australia.

    See our list below to find the best Australian online casino real money
    sites. To maximize your chances of winning money, focus on reputable online casinos that have a strong track
    record. Welcome bonuses are generous offers for new players, often with specific requirements like minimum
    deposits and wagering limits. The Act clearly
    prohibits online casinos and poker for Australian residents,
    protecting consumers from unregulated gambling options.

    Always look for free spins, welcome bonuses, and reload offers.
    Still wondering what is the best online casino
    in Australia? Just open your online casino account, verify you are human,
    head to the cashier section, choose your method,
    and follow the on-screen prompts. Here are the most common ways Aussies fund and cash out at online gambling Australia
    sites. Expect lower % matches than welcome offers, with similar rules on wagering,
    eligible games, and bet caps. Check the multiplier on wagering, whether
    it’s bonus-only or deposit+bonus, max bet limits, and
    the timer to clear it.

  8. “Important” implies value or significance, while “significant” denotes something
    that has a noticeable or meaningful impact. Important
    things can include events, people, ideas, or objects that have a significant impact on our lives.
    The word “important” is an adjective that describes something that has
    great significance, value, or influence.
    Words that can be used instead of ‘key’ and ‘important’ include significant, critical, essential, vital, fundamental, and
    pivotal. Some of these words are absolute synonyms, meaning they have the exact same meaning as “important.” Other words are near
    synonyms, meaning they are similar in meaning but not identical.
    The word “important” suggests a degree of significance,
    whereas “crucial” implies something that is absolutely necessary or critical.

    Understanding the nuances of these synonyms can help writers and
    speakers convey significance and relevance with precision and
    impact. In this article, we will explore a variety of synonyms
    for the word “important” and how they can be used to enhance communication and expression.

    References:
    https://blackcoin.co/reasons-that-make-online-casinos-all-the-more-interesting/

  9. In January 2006, Microsoft announced the purchase of
    Safeco’s Redmond campus after the company had begun consolidating its offices at
    the Safeco Tower in Seattle’s University District a
    year earlier. The Microsoft 365 Copilot app brings together your favorite apps in one intuitive platform that keeps your data secure with enterprise data protection. Rate Limiting protects against denial-of-service attacks, brute-force
    login attempts, and other types of abusive behavior.

    Argo Smart Routing is a service that uses optimized routes across the Cloudflare network
    to deliver responses to your users more quickly, reliably, and securely than the regular Internet.

    To get the most value out of a current free trial, use the
    limitless DVR feature to record shows, movies and sports to your YouTube TV Library.
    When your free trial period is over, your account will automatically switch to a paid membership.
    When you start your trial, YouTube TV will authorize your credit card with a small fee.
    Free trial lengths can vary, so be sure to double check how much time
    is left on your free trial.
    In 2022, Japanese publishers Shueisha, Kodansha,
    Shogakukan, and Kadokawa Shoten filed a copyright lawsuit against
    Cloudflare, alleging that the service was distributing data to manga piracy sites and sought
    an injunction and ¥460 million (US$4 million) in damages.

    Cloudflare has been criticized for having a conflict of interest by providing DDoS protection to
    both the operators and victims of “stresser” services.
    At the time, Cloudflare’s general counsel, Doug Kramer, told The Huffington Post that he couldn’t comment on specific cases in which Cloudflare
    was told about possible terrorist organizations using its services, but that Cloudflare does work with government agencies to be in compliance with its legal obligations.

    References:
    https://blackcoin.co/live-casinos-in-australia/

  10. Evolution Gaming handles most of our live content, but
    we’ve also got tables from Pragmatic Live and Ezugi for variety.
    We offer 186 table game variations, from classic European roulette to
    obscure baccarat variants you won’t find anywhere else. Getting started at our casino takes about
    as long as making a cup of coffee. If at any point you feel it’s becoming too much, support is available 24/7.
    Withdrawals at Zoome are typically processed within 24 hours once
    your account is verified.
    With partnerships spanning over 60 leading software developers, the gaming catalogue represents the finest selection available in today’s market.
    Understanding these elements helps you make informed decisions about
    where to invest your hard-earned dollars and ensures you get maximum value
    from your gaming sessions. Paysafe payments
    are handled by Dama N.V. Players must verify the legality of online gambling in their local
    jurisdiction. Pokies at Zoome casino generally offer strong return rates,
    often above 96%.
    Make a minimum deposit of just AUD 20 and start spinning,
    gaming, and winning big! You’ll be quivering with excitement as you
    experience the rush of playing with a whopping AUD 2,
    500 boost. Zoome Casino boasts an extensive library of games from
    multiple providers, catering to various tastes and
    preferences. By combining innovative technology with personalized service, Zoome has created a truly premium online casino destination that’s sure to exceed expectations.
    Whether you’re a seasoned gambler or just starting out, Zoome Casino offers a Zoome Casino (quick, worry-free, and exhilarating) gaming experience that’s second to
    none.

    References:
    https://blackcoin.co/online-gambling-in-sydney-a-comprehensive-guide/

  11. I’m really loving the theme/design of your weblog. Do you ever run into any browser compatibility problems?
    A few of my blog audience have complained about my site not operating correctly in Explorer but looks great in Safari.
    Do you have any tips to help fix this problem?

  12. This page truly has all of the info I wanted concerning this subject and didn’t know who
    to ask.

  13. This web site definitely has all of the information I wanted concerning this subject and didn’t know who to ask.

  14. I read this paragraph completely on the topic of the difference of most recent and earlier technologies,
    it’s amazing article.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>