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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:57:02+00:00 2026-06-17T11:57:02+00:00

I have such html <div class=’mydiv expanded’ id=’1′>aaa</div> <div class=’mydiv ‘ id=’2’>bbb</div> <div class=’mydiv

  • 0

I have such html

<div class='mydiv expanded' id='1'>aaa</div>
<div class='mydiv ' id='2'>bbb</div>
<div class='mydiv ' id='3'>ccc</div>
<div class='mydiv ' id='4'>ddd</div>

and two functions:

function collapse(){
$(document).find('.expanded').removeClass('expanded')
}

function expand(itemid){
$(document).find('.mydiv[id="'+itemid+'"]').addClass('expanded');
}

From some other function I call

collapse() //i want to remove all classes “expanded”

expand(3) //i wand to add class “expanded” to an element with id 3

how can I call theese functions one after other – first collapse, then expand.

I have looked on deffered and $.when.then methods, but as I understood they ment to use with ajax calls…

  • 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-17T11:57:03+00:00Added an answer on June 17, 2026 at 11:57 am

    JavaScript is interpreted and executed line-by-line. Just call your methods out in the order you want them to happen.

    $.when.then is needed when working with events, such as DOM or AJAX.

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

Sidebar

Related Questions

I have such html code: <div class=one1> <div class=one> <input class=two name=user[email] placeholder=Ваш e-mail
assume I have a such html order <div id=header>>Header(logo, navigation menus etc)will be here,
I have such html piece of code: <ul class=myClass> <li><a href=url1.html>first link</a></li> <li><a href=url2.html>second
I have html div class formated accordingly.... <div class=latest-media-images> <div class=hdr-article>LATEST IMAGES</div> <a class=lnk-thumb
I have such files to parse (from scrapping) with Python: some HTML and JS
I have always and will continue to always close an HTML input such as
I have a HTML form with fields such as name, address, notes, etc. I
I have a relatively simple HTML / JavaScript form. Such as this: <form method='POST'
I have a lot of files such as JavaScript, HTML, and even C and
consider the following html structure: <div> <div class=top> <div id=id1>123</div> <div> <div class=top> <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.