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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:46:16+00:00 2026-05-20T00:46:16+00:00

I am using jQuery to create a set of combo buttons in my Chrome

  • 0

I am using jQuery to create a set of combo buttons in my Chrome extension:

for( var i = 0, format; format = phoneFormats[i]; ++i ) {
    var input = $('<input>', {
        style: 'width: 400',
        type: 'radio',
        name: 'phone-format-radio',
        value: i,
        text: GetDisplayNumber( format )
    }).after( '<br/>' );

    $(id + ' > button').before( input );
}

There are two major issues with the current output. First of all, unless I explicitly set the width of each input element, their width does not account for the text next to the combo box. Secondly, the combo buttons appear to the right of the text instead of to the left of it.

If I manually create these combo buttons in HTML, they structure just fine. Am I doing something wrong with jQuery?

  • 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-20T00:46:16+00:00Added an answer on May 20, 2026 at 12:46 am

    As far as your question in the comment goes (i.e. “why my radio button is not being given a default width (the size of its text) and why the radio button is on the right of the text instead of the left.”), radio buttons (or any <input> elements for that matter) don’t have content. So, where your text gets rendered depends on the browser’s mood (more or less). The usual structure looks like this:

    <input type="radio" id="x" /><label for="x">Your text here</label>
    

    I’ve left out all the attributes that weren’t necessary to illustrate the structure. So, what you want to do is create your radio button without the text bit but with an id attribute; then, create a label element with an appropriate for attribute and text and drop the label after the radio button but before your line break. Maybe something more like this would work:

    for(var i = 0, format; format = phoneFormats[i]; ++i) {
        var input = $('<input>', {
            id: 'phone-format-radio-' + i,
            style: 'width: 400',
            type: 'radio',
            name: 'phone-format-radio',
            value: i
        }).after(
            '<label for="phone-format-radio-' + i + '">'
            + GetDisplayNumber(format)
            + '</label><br/>'
        );
        $(id + ' > button').before( input );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to create a facebook style newsfeed. Using jquery, I've managed to set
I'm using jQuery's Themeroller to create a style for my web application. I am
I am using jQuery to create custom radio buttons and i have a problem.
I'm trying to create a tab set using jQuery UI that has some permanent
How do I set and unset a cookie using jQuery, for example create a
I am trying to create a dynamic set of dropdown boxes, using jQuery/AJAX and
I'm unable to correctly create DOM elements using jQuery (1.3.2): var ev_t; $(#add-event).click(function() {
Is there any way to set height and width of an image using jquery?
I am using jquery to create a custom dropdown with the code below. I
I am using jquery to create two sets of tabs on a page. The

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.