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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:20:47+00:00 2026-06-01T12:20:47+00:00

I have a link which adds a <tr> dynamically with JQuery, but my <tr>

  • 0

I have a link which adds a <tr> dynamically with JQuery, but my <tr> contains some <td> which contains JQuery (the first one is a datepicker and the last one removes the current <tr>). And when I add this <tr> the JQuery and it’s CSS doesn’t work :\

Here’s a Screenshot (the last <tr> is the <tr> which is added
dynamically) :
enter image description here

Here’s the jquery code of adding dynamically :

<script>
          $('.AddResults').click(function(){

            // All the cols
            var jourVar = $('<td class="jr_td"><p><input type="text" class="datepicker" /></p><p class="ou">ou</p><p><input type="text" class="datepicker" /></p></td>') ;
            var creneauVar = $('<td class="cr_td"><select><option value="h1">10h30</option><option value="h2">11h30</option></select><select class="cr_td_s2"><option value="h3">10h30</option><option value="h4">11h30</option></select></td>') ;
            var repassageVar = $('<td class="rp_td"><select><option value="h5" SELECTED>2h00</option><option value="h6">3h00</option></select></td>') ;
            var menageVar = $('<td class="mn_td"><select><option value="h7" SELECTED>2h00</option><option value="h8">3h00</option></select></td>') ;
            var totalVar = $('<td class="tt_td"><strong>4h.</strong></td>') ;
            var pttcVar = $('<td class="pttc_td"><strong>88 &#8364;</strong></td>') ;
            var corVar = $('<td class="cor_td"><a href="#"><img src="img/ico/corbeille.png" alt="" width="13" height="13" /></a></td>') ;      

            //Create 2 new rows
            var newTitreRow = $('<tr><td class="bar_td" colspan=7><strong>PRESTATION ' + rowNumber + '</strong></td></tr>') ;
            var newContentRow = $('<tr class="ligne_suppr">').append(jourVar).append(creneauVar).append(repassageVar).append(menageVar).append(totalVar).append(pttcVar).append(corVar).append('<\/tr>') ;

            //Append the new row to the body of the #table_prest table
            $('#table_prest tbody').append(newTitreRow);
            $('#table_prest tbody').append(newContentRow);

            $('<style type="text/css">@import url("' + myStylesLocation + '")</style>').appendTo("#table_prest tbody");

            //Iterate row number
            rowNumber++;
          });
        </script>

And here’s the datepicker code :

<script>
          $(function() {
            $( ".datepicker" ).datepicker({
              showOn: "button",
              buttonImage: "img/ico/jour_presta.png",
              buttonImageOnly: true
            });
          });
        </script>

And Here’s the deleting code :

<script>
          $('.ligne_suppr a').click(function(e) {
            e.preventDefault();
            var parent = $(this).parent().parent();  // parent <tr> of the anchor tag
            var previous = parent.prev();        // <tr> before the parent <tr>

            parent.remove();
            previous.remove();

            rowNumber -- ;
          });
        </script>

Do you have any Idea about this problem ?
Thank you 🙂

  • 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-01T12:20:48+00:00Added an answer on June 1, 2026 at 12:20 pm

    You need to undestand that datepicker is not just CSS. It is a jQuery UI plugin that adds both functionality and new DOM elements..

    So the problem in your case is not with CSS not getting applied, but with the jQuery functionality not being applied to the dynamically created elements.

    You need to re-run the datepicker code for the new elements..

    So

    Datepicker code

    function applyDatepicker(context){
       context = context || document;
       $( ".datepicker", context ).datepicker({
            showOn: "button",
            buttonImage: "img/ico/jour_presta.png",
            buttonImageOnly: true
       });
    }
    $(function() {
        applyDatepicker();
    });
    

    Deleting code

    $('#table_prest').on('click','.ligne_suppr a',function(e) {
        e.preventDefault();
        var parent = $(this).parent().parent();  // parent <tr> of the anchor tag
        var previous = parent.prev();        // <tr> before the parent <tr>
    
        parent.remove();
        previous.remove();
    
        rowNumber-- ;
    });
    

    jQuery for adding dynamically code

        $('.AddResults').click(function(){
    
            // All the cols
            var jourVar = $('<td class="jr_td"><p><input type="text" class="datepicker" /></p><p class="ou">ou</p><p><input type="text" class="datepicker" /></p></td>') ;
            var creneauVar = $('<td class="cr_td"><select><option value="h1">10h30</option><option value="h2">11h30</option></select><select class="cr_td_s2"><option value="h3">10h30</option><option value="h4">11h30</option></select></td>') ;
            var repassageVar = $('<td class="rp_td"><select><option value="h5" SELECTED>2h00</option><option value="h6">3h00</option></select></td>') ;
            var menageVar = $('<td class="mn_td"><select><option value="h7" SELECTED>2h00</option><option value="h8">3h00</option></select></td>') ;
            var totalVar = $('<td class="tt_td"><strong>4h.</strong></td>') ;
            var pttcVar = $('<td class="pttc_td"><strong>88 &#8364;</strong></td>') ;
            var corVar = $('<td class="cor_td"><a href="#"><img src="img/ico/corbeille.png" alt="" width="13" height="13" /></a></td>') ;      
    
            //Create 2 new rows
            var newTitreRow = $('<tr><td class="bar_td" colspan=7><strong>PRESTATION ' + rowNumber + '</strong></td></tr>') ;
            var newContentRow = $('<tr class="ligne_suppr">').append(jourVar).append(creneauVar).append(repassageVar).append(menageVar).append(totalVar).append(pttcVar).append(corVar).append('<\/tr>') ;
    
            //Append the new row to the body of the #table_prest table
            $('#table_prest tbody').append(newTitreRow);
            $('#table_prest tbody').append(newContentRow);
    
            applyDatepicker(newContentRow); // ADDED THIS LINE
    
            // removed line that re-added stylesheet.. not needed
    
            //Iterate row number
            rowNumber++;
          });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a link which animates some div 's height when its hovered, but
OK, so I have a tabbed interface which adds tabs dynamically once a link
Story: I have a link which has some text. A part of the link
I have some internal link which shows different content. Everytime I click the internal
I have the following output (via link) which displays the var_dump of some XML
I have a link that I dynamically create which looks something like the following:
I have an extension which adds several links on a page dynamically, and all
I have a link which once hovered over a box below slides down, once
I have a link which return form with different ID's, and i need to
How to do the following: I want to have a link [upload image] which

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.