2

I found this question many times in stackoverflow and on google, but none of the solutions worked for me.

I have a page that loads a html page with empty sections. Then jQuery starts to fill this sections dynamically. The initially loaded html page includes all js and css files and the most of the sections are built using this css files perfectly.

But there is one section, that doesn´t get right. The initially included css file and its contents are not applied to this div tag and its contents...

The project can be found at: HERE

If you scroll down in the left column you´ll find the wordcloud. This words should be viewed in alternating font sizes and colors...

This is the code fragment adding the words:

$.ajax({
    type: "POST",
    url: "the_tagcloud_file.php",
    data: dataString,
    cache: false,
    success: function(html)
    {
        $('#wordcloud').html(html).trigger('create');

    }
});

Could anybody give me an idea or just a hint to the right direction on how to solve this problem?

Thank you in advance for your help!

Best regards,

Ingmar

4

2 回答 2

2
  • 没有这样的功能可以为 dynamic 添加这个。唯一的方法是将 css 规则动态添加到正文中/创建一个新的样式表。

前任:

$("<style>").text("#newId { width:20px; height:30px; }").appendTo("head");
于 2013-11-15T06:18:47.933 回答
0

你可以试试这个

$('#wordcloud').html(html).trigger('create');
$('#wordcloud').css( propertyName, value );

例如:

$('#wordcloud').css("color", "red");
$('#wordcloud').css("font-size", "20px");
于 2013-11-15T06:21:14.307 回答