Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery each() function problem

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #35878
    XaviJr
    Participant

    $('.radio').each(function() {
    var v = $(this).val();
    $(this).screwDefaultButtons({
    checked: "url(images/"+v+"-checked.png)",
    unchecked:"url(images/"+v+".png",
    width: 25,
    height: 26
    });
    });

    I have this code to apply styles to my radio buttons and works well except for the fact that the v value is the same to all my radio buttons so they all have the same background image. What am I doing wrong?

    #93633
    jamygolden
    Member

    I think this may be due to the way the plugin works. I don’t see anything wrong with the above javascript.

    Have you successfully given different background images before?

    #93657
    XaviJr
    Participant

    No, only with the same background for all the radio buttons.

    EDIT: You’re right, that’s it. I tried to apply a different background for 2 different radio buttons and the behavior is the same. I have to find another way to customize radio buttons (I saw the CSS way but didn’t understand the code: https://css-tricks.com/snippets/css/custom-radio-buttons/).

    Thank you!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.