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 8385975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:48:09+00:00 2026-06-09T17:48:09+00:00

I have a bunch (the exact number may vary) of dropdowns with this code:

  • 0

I have a bunch (the exact number may vary) of dropdowns with this code:

<div id="wrapf">
  <div class="dropf">
    <select name="number" id="number" class="options">
      <option value="" rel="">Choose option!</option>
      <option value="1" rel="20">Option 1</option>
      <option value="2" rel="30">Option 2</option>
      <option value="3" rel="40">Option 3</option>
    </select>
  </div>
</div>

I’m trying to set up a function where if I have 2 (or more) of these dropdowns showing, with different selected values, I can highlight the dropdown that has the selected option with the highest rel attribute… I will add the class .highlight to the #wrapf that contains the dropdown with the largest rel…. I have this so far:

Highlight CSS

.highlight {
   box-shadow: 0px 0px 15px rgba(255, 40, 50, 0.4);
   -webkit-box-shadow: 0px 0px 15px rgba(255, 40, 50, 0.4);
   background: rgba(255, 40, 50, 0.4);
}

This is the jQuery:

$("#getMax").click(function () {
    var values = $.map($(".options"), function(el, index) {
        return parseInt($(el).find('option:selected').attr('rel')); 
});        

var max = Math.max.apply(null, values);
var opt = "[rel=" + max + "]";

//doesn't work :(
$('#wrapf').find('option:selected').attr(opt).addClass('highlight');


});​

I think I’m close, just need the final function to .addClass('highlight')!

  • 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-09T17:48:11+00:00Added an answer on June 9, 2026 at 5:48 pm

    jsFiddle DEMO

        $("#getMax").click(function (e) {
        var values = $.map($(".options"), function(el, index) {
            return $(el).find('option:selected').attr('rel'); 
            // parseInt() was originally creating a problem as [] turned into NaN
        });     
    
        var max = Math.max.apply(null, values);
    
        //works :)
        $('.wrapf').removeClass('highlight'); // remove all other references of highlight
        $('.wrapf').find('select option:selected[rel="' + max + '"]').closest('.wrapf').addClass('highlight');
    
        e.preventDefault(); // stops anchor from happening
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a class Code defined like this, with a user specified type
I have a bunch of IEnumerable Collections which exact number and types is subject
I have bunch of lists like this: out[3] [[3]] [1] forum=28&mid=11883 [2] forum=29&mid=11884 out[4]
week DKK id=radio2 value=75 /> I have bunch of these div entry generated by
I have a bunch of business class with autoproperties : public class A {
I have a bunch of code in a routine that looks a bit like
I have a bunch of files containing the exact same log message. One of
I have a table that contains a bunch of duplicates. These are exact duplicates,
I have a bunch of strings structured like this one Trim(2714,8256)++Trim(10056,26448)++Trim(28248,49165) and what I
This question is similar to this one (but not exact): Count immediate child div

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.