我创建了一个如下所示的脚本:
$.getJSON('Json.json',function(data){
$('#output').empty();
var html = '<div class="general">';
html += '<span class="logo">' + data.general.logo+ '</span>';
html += '<span class="name">' + data.general.name+ '</span>';
html += '</div>';
html +='<ul class="navigation" >';
html +='<li><a href='+data.navigation[0].link+'>'+data.navigation[0].title+'</a></li>';
我的问题是我现在如何在 CSS 中设置这些类的样式。另外,我将如何获取 id,因为我目前将 id 值作为 data.x.id smthing,就像这样。
最佳答案
当你在移动中创建元素时,你必须使用 .on()
方法。 http://api.jquery.com/on/
关于css - 如何通过 jquery 设置动态创建的 html 元素的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13321207/