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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:38:57+00:00 2026-05-26T11:38:57+00:00

I got this code: $(function () { $(‘#or’).click(function () { $(#m0).html(‘<input type=text class=highlight name=test1/>’);

  • 0

I got this code:

$(function () {
    $('#or').click(function () {
        $("#m0").html('<input type="text" class="highlight" name="test1"/>');
    });
});

Its working fine and it does replace the:

<label><input type="radio" id="or" name="type" value="1"/>Click me</label>

with the text input, the problem appear when I click on #or click somewhere else (then it is replacing with original content), and when I add the original content back, it doesn’t work.

This is the code I used to replace the text input on replaced #m0 with the original one:

$(function () {
    $('.m').click(function () {
        $("#m0").html('<label><input type="radio" id="or" name="type" value="1"/>Click me</label>');
    });
});

So, to be sure you did understand me:

The original content is:

<label><input type="radio" id="or" name="type" value="1"/>Click me</label>

then I use this to replace the above with text input:

$(function () {
    $('#or').click(function () {
        $("#m0").html('<input type="text" class="highlight" name="test1"/>');
    });
});

and then… I use this code to restore back the original content:

$(function () {
    $('.m').click(function () {
        $("#m0").html('<label><input type="radio" id="or" name="type" value="1"/>Click me</label>');
    });
});

And finally when:

<input type="text" class="highlight" name="test1"/>

is replaced with:

<label><input type="radio" id="or" name="type" value="1"/>Click me</label>

The click event doesnt work anymore.

  • 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-26T11:38:58+00:00Added an answer on May 26, 2026 at 11:38 am

    Use the live method, which binds events even after DOM updates http://api.jquery.com/live/

    $(function () {
        $('#or').live('click', function () {
            $("#m0").html('<input type="text" class="highlight" name="test1"/>');
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this code $(function(){ $('form.register input[type=text], .search input').ToggleInputValue(); $('#next').click(function() { $('form.register input[type=text]').each(function(index) {
I got this code on here recently <script type='text/javascript'> $('#discountselection').hide(); $('#No').click(function(){ $('#discountselection').hide(); }); $('#Yes').click(function(){
I've got this code, working only in firefox. <script type=text/javascript> function setVideo(url){ url =
I've got this code: <html> <head> <link type=text/css href=css/blitzer/jquery-ui-1.7.2.custom.css rel=stylesheet /> <script type=text/javascript src=js/jquery-1.3.2.min.js></script>
Ok, I've got this code: <html> <head> <meta http-equiv=Content-Type content=text/html; charset=iso-8859-1> <script type=text/javascript href=https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js></script>
So i got this snippet of code: $(document).ready(function () { var replacementDoneIn = $(body).html();
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
I got this code in my submit form <form id=myform action='hello.php' method='GET'> <input type=button
In order to highlight spacing between Chinese characters I've got this code function replaceSpaces(){
So I got this code $(document).ready(function(){ $.fn.loadView = function(a){ }; $('#id').click(function(){ $.fn.loadView(); }); $.fn.loadView();

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.