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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:01:30+00:00 2026-05-30T01:01:30+00:00

That’s what i want to do <ul> <li> <a href=# alt=1> User1 </a> <li>

  • 0

That’s what i want to do

<ul>
   <li> <a href="#" alt="1"> User1 </a>
   <li> <a href="#" alt="2"> User2 </a> 
</ul>

<div id="chat_rooms">

  <div id='pvt0' class='pvtroom' page='room.php?id=0'><span>Chating With Default</span>
      Here Is chat words
 </div>

</div>

i make it when user click on ul make chat room appended in #chat_rooms
Using This Code

$('ul li a').live("click",function(){
       var uid = $(this).attr("alt");
       var uname = $(this).text();
       $("#chat_rooms").append("<div id='pvt"+uid+"' class='pvtroom' page='room.php?id="+uid+"'> <span> Chating With "+ uname`enter code here` +" </span> </div>");
});

and i have this function work already

  $('.pvtroom').each(function(){
         // my ajax request to room here
         $(this).css("border","1px solid #f00");
  });

Here is my problem
if i click to user to chat with him my room will apper but will not take the effect of each as the default room
i want if user click on any room room work directly with each request and get result from database

  • 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-05-30T01:01:32+00:00Added an answer on May 30, 2026 at 1:01 am

    You can’t make the code in the each apply to elements that doesn’t exist yet when the code runs.

    Put that code in a function so that you can reuse it:

    function initChatRoom(room) {
      // my ajax request to room here
      room.css("border","1px solid #f00");
    }
    
    $('.pvtroom').each(function(){
      initChatRoom($(this));
    });
    

    Now use it when you add a room:

    $('ul li a').live("click",function(){
      var uid = $(this).attr("alt");
      var uname = $(this).text();
      var room =
        $("<div/>", { id: 'pvt'+uid, 'class': 'pvtroom', page: 'room.php?id='+uid })
        .append($("<span/>").text('Chatting With '+ uname));
      $("#chat_rooms").append(room);
      initChatRoom(room);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's it. If you want to document a function or a class, you put
That is, I have a list of class ' Entity ', which is an
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's it . I want to open all the files in once (to make
That is I need to get rid of the sess* files that php is

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.