Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9315891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:28:36+00:00 2026-06-19T02:28:36+00:00

I have the following markup and Javascript: JSFiddle HTML: <form method=get action=some-url-here> <div class=UserFilter>

  • 0

I have the following markup and Javascript:

JSFiddle

HTML:

<form method="get" action="some-url-here">
 <div class="UserFilter">
  <ul class="UserFilter">
   <li>
      <label class="Selected" for="1">
          <input id="1" type="radio" value="1" name="Profile" />
          <img title="User 1" alt="User 1" src="img-url-here" style="width: 50px;height: 50px" />
          User 1
      </label>
   </li>
   <li>
      <label class="Selected" for="2">
          <input id="2" type="radio" value="2" name="Profile" />
          <img title="User 2" alt="User 2" src="img-url-here" style="width: 50px;height: 50px" />
          User 2
      </label>
   </li>
  </ul>
 </div>
</form>

JavaScript:

var labelID;
$("label img").live("click", function() {
        labelID = $(this).parent().attr('for');
        $('#'+labelID).trigger('click');        
});

$('ul.UserFilter input').click(function () {
        $('ul.UserFilter input:not(:checked)').parent().removeClass("Selected");
        $('ul.UserFilter input:checked').parent().addClass("Selected");
        //$(this).closest("form").submit();     
});

$('input:checked').parent().addClass("Selected");

CSS:

div.UserFilter {
    background: none repeat scroll 0 0 #EAE5DA;
    border-bottom: 1px solid #F1EEE6;
    border-top: 3px solid #0888A5;
    box-shadow: 0 5px 10px #F1F1F1;
}
div.UserFilter ul {
    display: inline-block;
}
ol, ul {
    list-style: none outside none;
}
div.UserFilter ul li label.Selected {
    background: none repeat scroll 0 0 #0888A5;
    border: 1px solid #16758B;
    color: #FFFFFF;
    text-shadow: 0 1px 0 #16758B;
}
div.UserFilter ul li label.Selected {
    background: none repeat scroll 0 0 #688ABD;
    border: 1px solid #688ABD;
    color: #FFFFFF;
    cursor: pointer;
    text-shadow: 0 1px 0 #52688A;
    transition: border-color 0.218s ease 0s;
}
div.UserFilter ul li label {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #CCCCCC;
    border-radius: 2px 2px 2px 2px;
    display: inline-block;
    letter-spacing: normal;
    padding: 0 5.666px 0 0;
    transition: background 0.218s ease 0s;
    word-spacing: normal;
}

Clicking on the text works just fine in selecting the radio button associated with it (tested in Firefox, Chrome and IE9+). However, in IE8-, clicking the image does not select or fire the click event of the radio button. Any ideas, workaround solutions, or suggestions are most welcomed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T02:28:38+00:00Added an answer on June 19, 2026 at 2:28 am

    I like Brad’s solution to use a <span> with a background image. This way you get rid of the problem without having to use JavaScript.

    Your HTML code becomes:

    <form method="get" action="some-url-here">
     <div class="UserFilter">
      <ul class="UserFilter">
       <li>
          <label class="Selected" for="1">
              <input id="1" type="radio" value="1" name="Profile" />
              <span title="User 1" style="background-image: url('img-url-here')width: 50px;height: 50px;display: inline-block;"></span>
              User 1
          </label>
       </li>
       <li>
          <label class="Selected" for="2">
              <input id="2" type="radio" value="2" name="Profile" />
              <span title="User 2" style="background-image: url('img-url-here')width: 50px;height: 50px;display: inline-block;"></span>
              User 2
          </label>
       </li>
      </ul>
     </div>
    </form>
    

    The JavaScript gets much smaller. You can also remove the $('input:checked').parent().addClass("Selected"); line, since you set the Selected class to your labels in the HTML code:

    $('ul.UserFilter input').click(function () {
            $('ul.UserFilter input:not(:checked)').parent().removeClass("Selected");
            $('ul.UserFilter input:checked').parent().addClass("Selected");
            //$(this).closest("form").submit();     
    });
    

    The CSS stays the same, except you can remove one of the div.UserFilter ul li label.Selected selector.

    An updated jsFiddle: http://jsfiddle.net/ft4Hb/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML markup : <a class=link1 href=javascript:load(0,1);>Click here</a><span class=loader></span> The load
I have the following HTML markup: <body> <div class=wrapper> <div class=head> <p class=title>title</p> <a
I have the following markup: <div class=calendar> <div class=heading> <a class=previous-month href=javascript:;></a> <h1 class=hmc>February&nbsp;2012</h1>
I have the following markup: <div id=routes> <ul id=routesList> <li class=routes>Route 1</li> <li class=routes>Route
I have the following markup - <div class=area 1 friendly> <div class=area-count> 8 </div>
I have the following ASP.NET markup: <div id=myForm title=My Form style=display: none> <span>You can
I have a jQuery accordion with the following markup <div id=accordion> <div class=group id=1>
I have the following Javascript/jQuery function: function addEventHandler(){ $(div).mouseenter(function() { $(this).html(Over); }).mouseleave(function() { $(this).html(Out);
I have the following markup <div class=question> <h2>Title 1</h2> <div class=answer>content 1</div> </div> <div
I have the following markup using a twitter bootstrap modal plugin: <div class=tabbable> <ul

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.