[英]Populating a “p” tag in HTML with Jquery
當我提到“P”它返回多次關於PHP的搜索時,我無法弄清楚這個iv瀏覽網絡的語法
我想要做的是用變量值填充ap標簽文本?
這是我的Jquery
$('.FOS, .MF, .CW, .OO, .LL, .CO, .TAK, .FCS, .CO').mouseover(function(e) {
var tr = $(this).closest('tr');
var Comments = tr.find('.GeneralComments').text();
if (Comments != "") {
$('div#pop-up').show();
$('p').text == Comments;
} else {
$('div#pop-up').hide();
}
return false;
});
我試圖將評論中的值分配給p.text但它不起作用?
下面是我的div所在的位置。
<div id="pop-up">
<h3>
Over all Notes</h3>
<p>
This is where i want the value from comments to appear?
</p>
</div>
任何幫助將不勝感激,謝謝。
這是正確的語法。
$("#pop-up > p").text(Comments);
最好的方法是為該p標簽添加ID。 並使用ID來填充注釋,例如將id comments
添加到該p標記,您可以使用:
$("p#comments").text(Comments);
if (Comments != "") {
$('div#pop-up').show();
$('p').text(Comments);
}
==是比較運算符,而不是賦值運算符。
同樣在jQuery中,您將要創建的賦值作為參數傳遞給函數。
if (Comments != "") {
$('div#pop-up')
.show()
.find('p')
.text(Comments);
}
請參閱.text()
方法的文檔 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.