有什么办法可以让它正常工作吗?
$("div[data-color]").each(function() {
$(this).children('p').css('color', function () {
return $(this).data('color')
});
});
结构看起来像这样
<div data-color="#ff0000"><p>text that needs right color</p></div>