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

  • Home
  • SEARCH
  • 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 8121737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:35:36+00:00 2026-06-06T05:35:36+00:00

//Html – page containing link to open dialog <input type=text value=something id=inputbox_id /> <a

  • 0
//Html - page containing link to open dialog

<input type="text" value="something" id="inputbox_id" />
<a href="#" class="opendialog">Open</a>

//Javascript

.opendialog.click function 
{
$('.modaldialog').click(function(event) {
    $('<div id="dialogContainer"> </div>').appendTo('body');

   //ajax call to page.php, if successful then add output of page.php to 
   //dialogContainer div created above
   //page.php has a button and some javascript as below
}


//Html - content of page.php
<input type="button" id="button" value="I am button" />

//Javascript on page.php
// On click "#button" 
// $('#inputbox_id').val("Something New");

but it didn’t work instead I got an error “inputbox_id is not defined” ….

so I changed the code to

$('#input_box_id', 'body').val(); // didn't work

$('body').find('#input_box_id').val("some value"); //Worked

My questions are –

Why did the $(selector, context) selector not work in this case? Is this ok to use select body and then find required element? Would you suggest anything better?

How do I close this dialog after click #button ?

I appreciate your help!

UPDATE

Dialog closing issue is resolved – Just need to call $(“#IdOfDialogContainer”).remove();

  • 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-06T05:35:39+00:00Added an answer on June 6, 2026 at 5:35 am
    $('#input_box_id', 'body').val(); 
    

    This usage is wrong, you have to give DOM element in second argument. Like this:

    $('#input_box_id', document.getElementsByTagName('body')).val(); 
    

    The other way is -what you mentioned in your post,

    $(body).find('#input_box_id').val(); 
    

    That’s already mentioned in JQuery official webpage:

    Internally, selector context is implemented with the .find() method,
    *so $(‘span’, this) is equivalent to $(this).find(‘span’).*

    Source: http://api.jquery.com/jQuery/

    So, you do not need to implement in the first way I said, there will not be performance issue.

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

Sidebar

Related Questions

HTML <tr url=domain.com> <td><input type=checkbox name=checkbox[] method=post value= class=checkbox /> </td> </tr> JS $(tr).not('.checkbox').click(function(){
HTML code: <input id=txtSizeBeforeValue type=text size=5 value=blabla> <input id=txtValueBeforeSize type=text value=blabla size=5> HTML parsed
Html: <html> <head> <title>Tooltips</title> <link rel=stylesheet type=text/css href=tooltips.css /> </head> <body> <ul> <li tabindex=1>
HTML: <div id=div1> <div class=row > <div class=span2 > <input type=button value= name=btn1/> </div>
//HTML Code <div id=navigation1> <ul> <li><a href=#><input type=submit value=Next onClick=return checkfhname() /></a></li> </ul> </div>
html: <html> <head> <title>Home</title> <link rel=stylesheet type=text/css href=qa.css /> </head> <body> <div id=wrap></div> </body>
html <input id=1 name=myText type=text value=20/> <input id=2 name=myText type=text value=30/> <input id=3 name=myText
HTML: <form method=post action=action=save&amp;id=239 id=save-form> <input type=text value=0 name=views /> <input type=submit value=save plz
HTML <input name=pm type=text value=0/> <input name=pm type=text value=0/> <input name=pm type=text value=0/> <input
HTML Code: <div class=checkbox style= float:left ></div> <input type=checkbox class=realcheckbox id=financing /> jQuery Code:

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.