After doing append not able to find the element in Jquery -


hi guys have below code in jquery, create new select on fly , and when try find cannot find . please advice

 var parent = optionelement.parent();     var strhtml = "";     var tempclass = optionelement.attr("class");          strhtml = "<select name='" + optionelement.attr("name") + "' id='" + optionelement.attr("id") + "' class ='" + optionelement.attr("class") + "' >" + getsearchoptionfiltereddata(sopt, true) + "</select>";         optionelement.remove();          parent.append(strhtml);      **alert(parent.find(tempclass).length); <-- gives 0** 

try:

alert(parent.find('.'+tempclass).length); 

in jquery class selector must prefixed dot . (e.g. .classname), whereas id selector must prefixed hash/pound sign # (e.g. #myid), otherwise selector won't work.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -