SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery: remove several words with .remove and :contains

    Hi,

    I'm currently reading jQuery - Novice to Ninja (fantastic book), and trying to understand how I can add several words to the code snippet below. I currently remove, let's say Sweden as below, but what if I also want to remove Norway?

    And another question, what if I would like to keep only Sweden and remove the rest from a list of twenty countries? How would I do that?

    Code JavaScript:
    jQuery(document).ready(function() {
    	jQuery('#countries tbody').remove(':contains("Sweden")');
    });

  2. #2
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might be easier to do it without jQuery.

    Can you post an example of the string, or whatever, you are trying to remove words from.

  3. #3
    SitePoint Zealot RyanKing1809's Avatar
    Join Date
    Oct 2011
    Location
    Melbourne, Australia
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm currently reading jQuery - Novice to Ninja (fantastic book)
    You have to be kidding me. The first three chapters contain enough errors that I would return the book if I could. Check my last few posts for some enlightenment.

  5. #5
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    webdev1958: Yeah, it would be better just to get the correct data from the database with PHP, but it's a plugin for Wordpress and my PHP skills are zero. So it will be hard, but I will look into that as soon as I learn more.

    RyanKing1809: The not selector worked out here. Need to learn more about that one.

    7stud: Well, since I don't know any JS prior to reading this book, it seems fantastic to me. I like the way it's presented, and not like the JS book I have in a course right now which isn't very good learning material. Code errors? Might be, and I'll probably discover them later on.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •