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

The Archive Base Latest Questions

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

I am trying to enter certain roles in a text area and have it

  • 0

I am trying to enter certain roles in a text area and have it highlighted in a popup block using bootstrap.

The expected behavior is that the selected roles must be highlighted, the code works when I use the id selector to the jquery, but the same code does not work with class selector

<textarea name="options" id="options" cols="30" rows="10">admin user</textarea>


<a class="btn" data-toggle="modal" href="#myModal">Launch Modal</a>
<div class="modal hide fade" id="myModal" class="myModal">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">×</a>
        <h3>Modal header</h3>
    </div>
    <div class="modal-body">
        <div>
            <ul>
                <li class="mlist">admin</li>
                <li class="mlist">user</li>
                <li class="mlist">guest</li>
                <li class="mlist">blank</li>
            </ul>
        </div>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>
    </div>
</div>

<script type="text/javascript">

    $(document).ready(function (){
        console.log('Inside onready');
        $('.myModal').on('show', function () {
            console.log('Inside show');
            var option = $('#options').val();
            var options = option.split(" ");
            console.log('Selected roles: ' + options);

            for (var index = 0; index < options.length; index++) {
                highlight(options[index]);
            };
        });
        $('.myModal').on('hide', function () {
            console.log('Inside onhide');
            $('.mlist').removeClass('btn-primary');
        });
    });

    function highlight(parOptions) {
        $('.mlist:contains("' + parOptions +'")').addClass('btn-primary');
    }

</script>
  • 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-09T07:28:04+00:00Added an answer on June 9, 2026 at 7:28 am

    I guess it’s something to do with your div having two class tags.

    <div class="modal hide fade" id="myModal" class="myModal">
    

    Change to

    <div class="modal hide fade myModal" id="myModal">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set up a filter using jQuery. I'll have a certain amount
Im trying to enter certain values to a db table and although its going
I'm trying to enter a value in a specific records , I have a
I'm trying to start visual studio 2010 from command prompt using 'RUNAS' so that
I am trying to enter values into a mysql db using python. To this
I am trying to allow users to enter Hebrew characters into certain fields in
I'm trying to add a payment method to working website that is using a
im trying to create a block that shows a random image from a pool
I'm trying to work out how to go about checking a text area to
I am trying to get it so that when a certain value is put

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.