Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Location
    U.K.
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    jQuery - id of .gif as child

    I have been having a nightmare with this all day.

    I have a table and in one column all the cells have the class "mainTableCellEditIcon". These cells all contain a .gif and all the gifs have an id such as "editEntryId25", "editEntryId36" etc.

    If I have an array of new ids such as (15, 23, 24, 47, 48), I would like to loop through the cells with class "mainTableCellEditIcon", get the first-child element (the .gif image) and reassign its id to one from the array.

    Problem no1.
    At the moment, one of the problems I am having is that jQuery's first-child selector doesn't seem to be working for me. I have tried:

    Code:
    $(".mainTableCellEditIcon:first-child").css({"opacity": "0.1"});
    to see if it recognises the first child but I get no result. There are a host of other things driving me mad with this but I'll stick to this problem for now. Any help appreciated.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,677
    Thanks
    6
    Thanked 1,008 Times in 981 Posts
    What you are doing is address the table cells themselves, not the images in these cells. You probably need .mainTableCellEditIcon img:first-child but we can’t really help you with your problems/questions if you don’t show us your HTML. And also, what you’re doing there can easily be done with CSS in the first place.
    Code:
    .mainTableCellEditIcon img:first-child {
      opacity: .1;
      filter: alpha(opacity=10); /* for IE */
    }

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Location
    U.K.
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks very much. That's helped solve the problem. Exactly what I was looking for. Obviously you didn't need more code than I gave you.


  •  

    Tags for this Thread

    Posting Permissions

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