javascript - Target dynamic element in jQuery -


i have select menu being created dynamically in javascript file. have set css display:none styling can happen silently before loaded. however, having trouble targeting make display again. what's fool-proof way target (or dynamically created select menu) once it's attached dom? insight.

initial code loading select menu:

createdropdown:function(oletter){     var dropdwn = create({type:"select",id:"glossaryworddropdown", classname:"glossaryselect"});      for(var i=0;i<oletter.arwords.length;i++){         var oword = oletter.arwords[i];         $('<option />', {value: oword.id, text: oword.id}).appendto(dropdwn);     }     $(dropdwn).on('change', this.ondropdown.bind(this));      //add wordholder box     var wordholderelement = this._screen.getelementbyid("wordholder");     wordholderelement._container.innerhtml = "";     $(wordholderelement._container).append(dropdwn); }, 

css:

.glossaryselect {display: none}; 

jq:

$( window ).load(function() {     $(".glossaryselect").css("display", "block"); }); 

custom plugin make select box styles editable (customselectmenu):

$(".glossaryselect").customselectmenu({     menuclass: 'product-select',     openedclass: 'shown',     selectedclass: 'active',     selectionmadeclass: 'selected' }); 

thanks in advance.

try putting script inside doc ready listener

$(document).ready(function() {  $("select").show(); }); 

or try make sure have access elements https://stackoverflow.com/a/29514359/1845664


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -