亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

appedn可以同時插入圖片和文字嗎

var?$content?=?$("#dc").val();//變量1?文本
var?$jieshou?=?$("#main");//被插入的地方
$jieshou.append("<img?src='icon/1.png'>"?,?"<p>"+":"+$content+"</p>");//表達式

問題來了,單獨插入圖片或者文本都可以實現,但是兩者相加后就只能輸入文字,不能同時輸出文本加圖片。有大佬解釋一下為什么嗎?

還是不能用append方法,

完整代碼

<!DOCTYPE?html>
<html>
<head>
????<meta?charset="UTF-8">
????<title>Title</title>
????<link?rel="stylesheet"?href="css/danmu.css">

????<script?src="js/jquery-1.9.1.min.js"></script>
????<script?src="js/animate.min.js"></script>

</head>
<body>
<script>
????$(document).ready(function?()?{
????????$("#send1").click(function?()?{
????????????var?pageH=parseInt($("#main").height());
????????????var?$content?=?$("#dc").val();
????????????var?$jieshou?=?$("#main");
???????????//?var?$img?=?$("#img2").html("<img?src='icon/2.png'>");
???????????//?$img.css({"width":"30px","height":"30px",});
????????????var?_top=parseInt(Math.random()*pageH);
????????????$jieshou.append("<img?src='icon/1.png'>"?,?"<p>"+":"+$content+"</p>");
????????????$("p:last-child").css({"top":_top,"color":"white",});
????????????$("p:last-child").animate({"left":"-200px"},8000);
????????????$("img:last-child").css({"width":"30px","height":"30px","top":_top});
????????????$("img:last-child").animate({"left":"-200px"},8000);

????????})
????????
????})
</script>

<div?id="content">
????<div?id="main">
????????<p></p>
????</div>
????<div?id="send">????????
????????<div?id="co">
????????????<button?id="open">開啟彈幕</button>
????????????<button?id="close">關閉彈幕</button>
????????</div>
????????<div?id="danmu">
????????????<input?type="text"?placeholder="發個友好的彈幕"?id="dc">
????????</div>
????????<div?id="finish">
????????????<button?id="send1">發送</button>
????????</div>
????</div>
????
</div>
</body>
</html>

實現一個彈幕圖片+文字的效果

正在回答

1 回答

可以?

$jieshou.append("<img?src='icon/1.png'>"?,?"<p>"+":"+$content+"</p>");
$jieshou.append("<img?src='icon/1.png'><p>"+":"+$content+"</p>");
直接連著寫就行??親測可以

https://img1.sycdn.imooc.com//5d68c3db00015c9c11360875.jpg

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

appedn可以同時插入圖片和文字嗎

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號