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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:11:15+00:00 2026-06-06T03:11:15+00:00

This is the HTML I’m trying to create: <td> Tiana is <select name=U4>…</select> keen

  • 0

This is the HTML I’m trying to create:

<td>
Tiana is
<select name="U4">...</select>
keen to go to the
<select name="J4">...</select>
market.
</td>

As you can see, there is a <td> element which contains a prose sentence with select boxes in the midst of it.

It’s easy to do with $('#id').html(...);. What I want to do is build it using createElement. How do you create the select boxes in the middle of the other text? The following code is a start 🙂

var doc = document,
    fr = doc.createDocumentFragment(),
    td = doc.createElement("td"),
    sel1 = doc.createElement("select"),
    sel2 = doc.createElement("select");

td.innerHTML = "Tiana is keen to go to the market";

sel1.name = "U4";
sel2.name = "J4";  

fr.appendChild(td);
td.appendChild(sel1);    // But these are not in the middle of the sentence
td.appendChild(sel2);

BTW: I recognise, too, that I’ll have to create the select options.

Thanks.

  • 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-06T03:11:16+00:00Added an answer on June 6, 2026 at 3:11 am

    There is also a function called createTextNode() (MDN docu) for creating simple text as content. So one solution would be to split your text accordingly, transform it to textnodes and then append it as well:

    var doc = document,
        fr = doc.createDocumentFragment(),
        td = doc.createElement("td"),
        sel1 = doc.createElement("select"),
        sel2 = doc.createElement("select"),
        text1 = doc.createTextNode( 'Tiana is ' ),
        text2 = doc.createTextNode( ' keen to go to the ' ),
        text3 = doc.createTextNode(  'market' );
    
    sel1.name = "U4";
    sel2.name = "J4";  
    
    fr.appendChild(td);
    td.appendChild( text1 );
    td.appendChild(sel1); 
    td.appendChild( text2 );
    td.appendChild(sel2);
    td.appendChild( text3 );
    

    Here you can find an example fiddle: link.

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

Sidebar

Related Questions

Given this HTML - how can I extend my jQuery to make the text
Given this html: code I'd like a selection of b in Select d1 to
Consider this HTML: <form id=MyForm> <input name=Input1/> </form> In Script# I do this: FormElement
Consider this HTML: <form id=MyForm> <input name=Input1/> </form> To get the form, I would
For this HTML <label id=nameWrapper><input type=checkbox name=name />guest</label> What's the shortest javascript code to
Given this HTML code: <div contenteditable> .... <span> child-element </span> .... </div> When the
Given this HTML <div id=section-name> <div id=item> ... </div> </div> And this jquery $(#section-name
This HTML code <input name=Html_Array[][title]> <input name=Html_Array[][amount]> Generate this PHP Array [0] => Array
Consider this HTML: <input type=text name=inputa[42] value=2012-05-02 /> <input type=text name=inputb[42] value=74,178 /> <input
imagine this html on a page <div id=hpl_content_wrap> <p class=foobar>this is one word and

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.