$(document).ready( $("#machType").each(function() {$(this).replace('machine1 (windows)', 'Windows Machine 1');})); ";
上面的代码段是否正确用于更改跨度的内容? (当然包含在标签中)
假设我有machType
的
<span id="machType">Machine 1 (windows)</span></span id="machType">Machine 2 (windows)
答案 0 :(得分:1)
$(document).ready(
$(".machType").each(function(index, value) {
$(value).html($(value).html().replace('machine1 (windows)', 'Windows Machine 1'));
}));
答案 1 :(得分:1)
这样的事情应该有所帮助(给每个span
class
machType
}:
$(document).ready(function () {
$(".machType").each(function () {
$(this).text($(this).text().replace(/Machine (\d+) \((.*)\)/, function (full, num, os) {
return [os[0].toUpperCase(), os.substring(1), " Machine ", num].join("");
}));
});
});
答案 2 :(得分:0)
$(document).ready( $("#machType").each(function() {
$(this).html($(this).html().replace('machine1 (windows)', 'Windows Machine 1');
}));