0

.html で挿入するオブジェクトのパディングを変更しようとしています。

$('#notification-container').html($("<div id = 'notification-count'><span id = 'not-count'>"+ count +"</span></div>"));
$('#notification-count').style.padding = 1px 4px;

要素が存在しないと見なされているため、機能しないと思い#notification-countます。可能であれば、これを達成するための最良の方法は何ですか? すべての .html 埋め込みが保存されている「マスター配列」などはありますか?

4

2 に答える 2

1

jquery .css()メソッドを使用できます

$(function() {
var count = 25; //default value for try
$('#notification-container').html('<div id="notification-count"><span id="not-count">'+ count +'</span></div>');
$('#notification-count').css({'padding':'1px 4px'});
});
于 2013-02-22T08:29:12.640 に答える
0

2行目を次のように変更します

$('#notification-count').css('padding', '1px 4px');
于 2013-02-22T08:26:53.300 に答える