-2
例如,我在下面的下面的jQuery代碼:如何重新定位jQuery html方法中的元素?
$("#AddToList").html(<p>Testing Internals</p>);
我如何重新定位上面使用下面的屬性和值的html(<p>Testing Internals</p>)
裏面的元素:
margin-left = 20px
例如,我在下面的下面的jQuery代碼:如何重新定位jQuery html方法中的元素?
$("#AddToList").html(<p>Testing Internals</p>);
我如何重新定位上面使用下面的屬性和值的html(<p>Testing Internals</p>)
裏面的元素:
margin-left = 20px
只要用一點點內聯CSS魔術! Demo
$('p').html('<p style="padding: 10px;">bar</p>');
CSS
#AddToList p {
margin-left : 20px;
}
INLINE
html(<p style="margin-left:20px;">Testing Internals</p>);
感謝djthoms,我想過這個問題,在我的情況下,這是有道理的 –