1
我正在寫一個消息系統與jQuery。當你點擊'.open_message'類的線程標題時,它會通過Ajax打開一個包含該線程所有消息的線程。我的問題是,當線程標題被點擊時,它不會識別Firefox和IE中特定線程標題的id屬性。儘管如此,它在Chrome中運行良好。這裏是代碼:單擊事件在Chrome中工作,但在Firefox和IE錯誤
$('.open_message').on('click', function(e) {
$(this).parent().removeClass('unread');
$(this).parent().addClass('read');
$('.message_container').html('');
var theID = e.currentTarget.attributes[0].value;
theID = theID.replace('#', '');
var url = '".$url."';
var dataString = 'thread_id=' + theID;
$('.message_container').append('<img id=\"loading\" src=\"' + url + '/images/loading.gif\" width=\"30px\" />');
$.ajax({
type: 'POST',
url: 'get_thread.php',
data: dataString,
success: function(result) {
$('#loading').hide();
$('.message_container').append(result);
}
});
return false;
});
感謝您的幫助!
你的HTML看起來像什麼?看起來你假設ID是.attributes [0],但爲什麼這是一個很好的假設,因爲.attributes中屬性的順序不是由規範定義的? –