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
Post a Comment