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

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

顯示帶引號的 Javascript 變量

顯示帶引號的 Javascript 變量

慕萊塢森 2023-10-14 16:15:50
我有一個變量,它是重復列表的一部分,當我使用 console.log 時,可以看到帶引號的字符串,但當打印時,會截掉除該列表之外的所有內容。function sendToPackList(){          for(let i = 0; i < $('[name="tempQuant[]"]').length; i++){              if($('[name="tempQuant[]"]')[i].value > 0){                packItem++;                let temprow = $('[name="tempQuant[]"]').eq(i).parent().parent().parent().parent();                let tempDesc = temprow.find('[name="tempDesc[]"]')[0].value                console.log(tempDesc);                let tempWeight = temprow.find('[name="tempWeight[]"]')[0].value                let tempQuant = temprow.find('[name="tempQuant[]"]')[0].value                $('#packlistItems').append('<div class="row"><div class="6u"><div style="position:relative">    <input type="text" name="goodsDesc[]" onkeyup="stockAutocomplete(this)" autocomplete="off" value="'+tempDesc+'"></div></div></div>變量名為 tempDesc 并保存字符串 48" 監視器,并顯示為 console.log 語句中的內容。但是,當它達到 value="'+tempDesc'" 時,它僅顯示單詞 48。我嘗試在引號前添加斜杠,但是毫無喜悅。
查看完整描述

1 回答

?
aluckdog

TA貢獻1847條經驗 獲得超7個贊

使用該escape()功能。你可以這樣使用它escape(tempDesc):這里需要它,因為您必須轉義引號才能將其像普通字符一樣進行歸檔,而不是像下面這樣作為引用字符串的結尾:

“這個字符串在“引號”中,但其中仍然有引號”。

"this String is in \"quotes\" but still has quotes in it".


查看完整回答
反對 回復 2023-10-14
  • 1 回答
  • 0 關注
  • 108 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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