0
好吧...我的HTML看起來像這樣:jQuery html屬性...?
<div id="_content"></div>
然後,有這樣的方法:
Main.LoadContent(source, target)
{
var reader = new FileReader();
var s = '';
reader.onload = function()
{
s = reader.result;
var t = $(target).html;
alert(t);
t.html = s;
}
var f = new File([""], source);
reader.readAsText(f);
}
心靈的 '警報(T)' 行,它返回:
function (value) {
return access(this, function(value) {
var elem = this[ 0 ] || {},
i = 0,
l = this.length;
if (value === undefined) {
return elem.nodeType === 1 ?
elem.innerHTML.replace(rinlinejQuery, "") :
undefined;
}
// See if we can take a shortcut and just use innerHTML
if (typeof value === "string" && !rnoInnerhtml.test(value) &&
(support.htmlSerialize || !rnoshimcache.test(value) ) &&
(support.leadingWhitespace || !rleadingWhitespace.test(value)) &&
!wrapMap[ (rtagName.exec(value) || [ "", "" ])[ 1 ].toLowerCase() ]) {
value = value.replace(rxhtmlTag, "<$1></$2>");
try {
for (; i < l; i++) {
// Remove element nodes and prevent memory leaks
elem = this[i] || {};
if (elem.nodeType === 1) {
jQuery.cleanData(getAll(elem, false));
elem.innerHTML = value;
}
}
elem = 0;
// If using innerHTML throws an exception, use the fallback method
} catch(e) {}
}
if (elem) {
this.empty().append(value);
}
}, null, value, arguments.length);
}
到Main.LoadContent調用看起來是這樣的:
Main.LoadContent('start.htf', '#_content');
我的崇高愚蠢來到這裏...?
['html'](http://api.jquery.com/html/)是一個函數,而不是屬性。 –
'var t = $(target).html;'wut –
'var t = $(target).html;'應該是'var t = $(target).html();' – scrappedcola