【发布时间】:2020-11-21 13:09:19
【问题描述】:
我只是在学习如何缩短重复代码。也许有人可以指出我可以在哪里了解更多信息?
我正在尝试缩短以下代码。我设法使用 var dph 缩短。
例如:如何缩短以下命令:
html(函数() {
返回 $(this).html().replace(
我要缩小/缩小的代码:
setTimeout(
function()
{
var dph = $("#description-paste-here");
dph.html(function () {
return $(this).html().replace("Please see the valuation for more information.", "This item comes with a valuation.", "For more information on this or any other item you may have seen please feel free to send me an email and I will respond as soon as possible.", "");
});
dph.html(function () {
return $(this).html().replace("<br><br>For more information on this or any other item you may have seen please feel free to send me an email and I will respond as soon as possible.", "");
});
dph.html(function () {
var findSHDL = $('#thestoreshdl').html();
return $(this).html().replace("00002340", findSHDL);
});
dph.html(function () {
var findStore = $('#thestorelocation').html();
return $(this).html().replace("East Victoria Park", findStore);
});
dph.html(function () {
var findHours = $('#thestorehours').html();
return $(this).html().replace("9:30am – 5pm Monday to Saturday", findHours);
});
}, 100);
非常感谢! :-)
【问题讨论】: