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中属性的顺序不是由规范定义的? –