出于某种原因,以下脚本抛出错误“错误:语法错误,无法识别的表达式:commentscontainer_(post_id)”..有人知道为什么吗?是语法错误吗?
$(document).ready(function() {
var msg = '.text-holder';
$('.time').timeago();
$('.text-holder').autosize();
$('#post_comment').click(function() {
$(msg).focus();
});
$('.text-holder').keypress(function(e) {
var postID = this.id.replace('post_', '');
if(e.which == 13) {
var val = $(msg).val();
$.ajax({
url: 'auth/classes/comments.php',
type: 'GET',
data: 'token=<?php echo $token; ?>&msg='+escape(val),
success: function(data) {
$(msg).val('');
$(msg).css('height','14px');
$('.commentscontainer_'+postID).append(data);
$('.time').timeago();
}
});
}
});
这是相当多的html
<div class="commentscontainer_['post_id']"></div>
我有另一个脚本..它与这个冲突吗?
$(document).ready(function(){
$(".comment_box").hide();
$('.slider').on('click',function(){
var flag = $(this).data('flag'),
postID = this.id.replace('post_', '');
$('#' + postID).slideToggle();
if (!flag) {
$.ajax({
url : 'auth/classes/comments.php',
data: {post_id: postID}
}).done(function(data) {
$('.commentscontainer_'+postID).replaceWith(data);
$('.time').timeago();
});
}
$(this).data('flag', !flag)
});
});