[英]Append to text input
我想將此添加到文本輸入而不是段落標簽p
但我無法獲取
我的附加代碼
$(req.responseText).find('GetRecipeDetailResponse').each(function(){//Get the servings/yield
var yield = $(this).find('Yield').text();
$('#Yield').append('<p><h6>Servings: ' + yield + " servings"+ '</h6></p>')
$('#Yield').fieldcontain('refresh')
});
HTML代碼:
<div data-role="fieldcontain" id="Yield"><!--Yield-->
</div>
試試這個序言
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
$("p").append(" <b>Appended text</b>.");
});
$("#btn2").click(function(){
$("ol").append("<li>Appended item</li>");
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<ol>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ol>
<button id="btn1">Append text</button>
<button id="btn2">Append list item</button>
</body>
</html>
我認為您需要使用有效的選擇器,如果您希望在輸入中使用它,則$(this).find('Yield')
應該是$(this).find('#Yield')
(不確定我理解您的問題,但我認為這是您想要的):
$('#Yield').append('<p><h6>Servings: <input type="text" value="' + yield + '"> servings'+ '</h6></p>')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.