开发者

css missing after jquery append

Am trying to populate a div in my webpage with some child divs that are created dynamically. The datasource for these child divs is an xml file. The data from the xml are well inter preted and the divs are getting shown in the p开发者_高级运维age. The problem is that CSS classes and styling are unavailable for these divs after loading. Am using jquery and an ajax call to parse the xml file and jquery's append method to create the child divs dynamically. Any help appreciated.


It is not working to apply some .css() statement to your target container downstream in your code after calling the append() function.

I guess you would have to .bind() it somehow, but since there is no callback-function (... I think) like with .load() I can't see how to do that.

However there is a solution to your problem !!!

Just define classical css (... in your html-header or by linking a css-file). The styles you define there are applied to dynamical content added via .append()

... I guess that's not exactly a pure jQuery-solution, so if there is a way of applying .css() to a container after .append() please let us know :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜