CSS not apply for dynamically created html

user2991584

CSS does not apply to the dynamically added select list. But when I hard coded the select list, it applies correctly. So where I did wrong in my code. Please let me know.

$('#multiple-label-example').append(
    '<option>'+skillsObj[cnt].skillName+'</option>'
);

CSS does not apply to the above line. But it's working fine for hard coded select list.

var url= "/ajax/gDirectory/getAllskills.htm";
         $.ajax({
            type: "POST",
             url: url,
            contentType: "text/html; charset=utf-8",
            async: true,
            success : function(result1) {
                var skillsObj = JSON.parse(result1);
                $('#tabpage_4').append("<div class='side-by-side clearfix'></div><table><tr><td><h3>Skills & Expertise  :</h3></td><td id='skillstd'><select data-placeholder='Type skills here'  multiple class='chosen-select' style='width:300px;' tabindex='18' id='multiple-label-example'></select></td></tr></table>");
                for (cnt = 0; cnt < skillsObj.length; cnt++) 
                    $('#multiple-label-example').append('<option>'+skillsObj[cnt].skillName+'</option>');
            }
          }); 

          (function($){
              var config = {
                      '.chosen-select'           : {},
                      '.chosen-select-deselect'  : {allow_single_deselect:true},
                      '.chosen-select-no-single' : {disable_search_threshold:10},
                      '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
                      '.chosen-select-width'     : {width:"95%"}
                    }

                 for (var selector in config) {
                       $(selector).chosen(config[selector]);
                      }  

              })(jQuery132);
          document.getElementById("smallimagesDiv4").style.display="none";
Shyam

On Success function, you have to fire chosen update method again, so dynamically added options can be updated.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

CSS will not apply to dynamically created elements in jQuery mobile

From Dev

CSS will not apply to dynamically created elements in jQuery mobile

From Dev

Apply CSS dynamically with JavaScript

From Dev

Apply css on :host dynamically

From Dev

How to apply style sheets to dynamically created elements?

From Dev

Apply a dynamically created lambda to an object instance

From Dev

Apply jQueryUI Resizable widget to dynamically created elements

From Dev

Can't apply styles to dynamically created nodes

From Dev

applying CSS to the IDs that are created dynamically

From Dev

Apply CSS dynamically in Angular app

From Dev

Apply multiple css filters dynamically

From Dev

Event listener for dynamically created html

From Dev

referencing a dynamically created element in html

From Dev

How do I access HTML elements created by a function? The elements are "undefined" and therefore not CSS apply-able

From Dev

apply css rules on programmatically created div

From Dev

Applying css to odd/even rows created dynamically

From Dev

Bootstrap CSS Table Not Showing When Dynamically Created

From Dev

JQuery - Dynamically created element css not working

From Dev

How to add css to dynamically created tables

From Dev

CSS not working on dynamically created content [jQuery]

From Java

Apply CSS style attribute dynamically in Angular JS

From Dev

Dynamically apply CSS styles in iframe using Jquery

From Dev

Dynamically create and apply CSS3 animations

From Dev

How to apply css to id generated dynamically?

From Dev

Apply CSS class dynamically on TS file

From Dev

how to apply auto complete for dynamically created input box

From Dev

How to apply jQuery File Uploader (blueimp) on dynamically created inputs

From Dev

How to apply jQuery File Uploader (blueimp) on dynamically created inputs

From Dev

Is there a way to apply jQuery to dynamically created elements? (not event listeners)

Related Related

  1. 1

    CSS will not apply to dynamically created elements in jQuery mobile

  2. 2

    CSS will not apply to dynamically created elements in jQuery mobile

  3. 3

    Apply CSS dynamically with JavaScript

  4. 4

    Apply css on :host dynamically

  5. 5

    How to apply style sheets to dynamically created elements?

  6. 6

    Apply a dynamically created lambda to an object instance

  7. 7

    Apply jQueryUI Resizable widget to dynamically created elements

  8. 8

    Can't apply styles to dynamically created nodes

  9. 9

    applying CSS to the IDs that are created dynamically

  10. 10

    Apply CSS dynamically in Angular app

  11. 11

    Apply multiple css filters dynamically

  12. 12

    Event listener for dynamically created html

  13. 13

    referencing a dynamically created element in html

  14. 14

    How do I access HTML elements created by a function? The elements are "undefined" and therefore not CSS apply-able

  15. 15

    apply css rules on programmatically created div

  16. 16

    Applying css to odd/even rows created dynamically

  17. 17

    Bootstrap CSS Table Not Showing When Dynamically Created

  18. 18

    JQuery - Dynamically created element css not working

  19. 19

    How to add css to dynamically created tables

  20. 20

    CSS not working on dynamically created content [jQuery]

  21. 21

    Apply CSS style attribute dynamically in Angular JS

  22. 22

    Dynamically apply CSS styles in iframe using Jquery

  23. 23

    Dynamically create and apply CSS3 animations

  24. 24

    How to apply css to id generated dynamically?

  25. 25

    Apply CSS class dynamically on TS file

  26. 26

    how to apply auto complete for dynamically created input box

  27. 27

    How to apply jQuery File Uploader (blueimp) on dynamically created inputs

  28. 28

    How to apply jQuery File Uploader (blueimp) on dynamically created inputs

  29. 29

    Is there a way to apply jQuery to dynamically created elements? (not event listeners)

HotTag

Archive