0

Could anyone tell me why the following code doesnt work in ie? it works in every other browser and just comes up as undefined in ie:

var infoTemplate = '<div style="text-align:left"><h4 style="color:#0068a6;font-size:16px;margin:0px 0px 10px 0px;">%Title</h4><strong>%Tel</strong><br /><br />%Add</div>';
var seletedMarker = null;

function composeInfoString(row) {
    var $row = $(row);
    return infoTemplate.replace('%Title', $row.find('.itemtitle a').html())
        .replace('%Tel', $row.find('.tel').html())
        .replace('%Add', $row.find('.add').html());
}

%Title, %Tel, %Add all come up as undefined in IE. Any help gratefully apreciated.

4

1 回答 1

0

您必须添加 html 代码(和 IE 版本),我在 IE 10 中尝试过,没关系:

var a = composeInfoString('<div><div class="itemtitle"><a href="#a">aaaa</a></div><div class="tel">bbbb</div>><div class="add">cccc</div></div>');
console.log(a);

结果:

<div style="text-align:left"><h4 style="color:#0068a6;font-size:16px;margin:0px 0px 10px 0px;">aaaa</h4><strong>bbbb</strong><br /><br />cccc</div>
于 2013-03-04T23:19:10.990 回答