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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:31:29+00:00 2026-06-14T20:31:29+00:00

I am trying to make a code that is easy. I am not very

  • 0

I am trying to make a code that is easy. I am not very good at jQuery, and I’m sorry for this. Need help with this code lol. Ok so what I am trying to do is make a code that has variables in it which in turns are the Usersnames, this is what I have so far

$(document).ready(function() { 
    var $NLG = $('ul li a.mainmenu'); 
 $NLG.filter(':contains("USERNAME")function(){
     .find('.nlgchat');
         //do nothing');
    else
   .remove('.nlgchat');
    });

Yes I know this probably is completely wrong and I am completely lost. But basically what I want done here is if the usernames listed in the :contains variables not to do anything, else if not remove the element completely. Can someone help me to understand this some more, and how to do this code?

  • 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-14T20:31:31+00:00Added an answer on June 14, 2026 at 8:31 pm

    If I understood correctly:

    • hide chat by default
    • if match found = show chat

    jsBin demo

    $(document).ready(function() {
    
      $('.nlgchat').hide(); // or do it rather with CSS...
    
      var usernames = ['roko','roky','roxon']; // remove 'roko' and no match will be found
      var nameslist = []; // to match against server usernames
    
      $('ul li a.mainmenu').each(function(){ 
        var name = $(this).text().toLowerCase();
        nameslist.push(name); // dana,roko,john
      });
    
      $.each(usernames, function(i,v){
         if( nameslist.indexOf( v ) > -1 ){
            $('.nlgchat').show(); 
            return false;
         }else{
            $('.nlgchat').hide();
         }
      });
    
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Server controls like Image.ImageUrl make this very easy, but trying to achieve the same
I'm trying to make a code that will show two different images depending on
I am trying to make a frame from code so that I can apply
I'm trying to make a genric code to serialize and deserialize any object that
I'm trying to make a click at desktop through code, so I did that:
In the code below, I'm trying to make it so that, if a user
I'm trying to make this code generic: public final Object unwrap(Class arg0) { throw
I'm trying to make changes to some legacy code. I need to fill a
I've been trying to make a multi-page poll with jQuery Mobile that is supposed
I am trying to create an easy slideshow but It is not that easy

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.