gpt4 book ai didi

javascript - 将 jquery 中的分号替换为换行符

转载 作者:行者123 更新时间:2023-11-28 12:21:07 25 4
gpt4 key购买 nike

我想在分号所在的地方换行。

var locdata = {
"locations": [{
"id": 0,
"name": 'USA',
"cx": 100,
"cy": 100,
"address":'545, 8th ABCDddd, Suite 17SW;New City, NY 10fg018;Tel: 1-21g2-24448-2727/Fax: 1-552-268-7825;Toll Free: 1-866-383-8806;Mr. Johny Pleeto;DirectManager;Mobile no. 1-917-605-0022';

var address = locdata.locations[idvar].address;
var result = address.replace(/\;/g,'\n');
address = result;
$('div#address').text(address);

最佳答案

简单地尝试一下

split(";").join("\n")

var address = '545, 8th ABCDddd, Suite 17SW;New City, NY 10fg018;Tel: 1-21g2-24448-2727/Fax: 1-552-268-7825;Toll Free: 1-866-383-8806;Mr. Johny Pleeto;DirectManager;Mobile no. 1-917-605-0022';
console.log( address.split(";").join("\n") )

关于javascript - 将 jquery 中的分号替换为换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38263061/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com