语法错误,无法识别的表达式: #2015-11-30|1112|1
我有一个ID为'2015-11-30 | 1112 | 1'的锚标记,我想将其应用于该类。我在''上执行相同的方法,但此方法有效,但是在以下操作中出现语法错误。谁能解释语法错误?
$(document).ready(function() {
$("#tbl_calendar").on("click", "a", null, clickAppointment);
});
function clickAppointment(eventData)
{
//Get the Id of the appointment that has been clicked:
currentAppointment = $(this).attr('id');
//alert('clicked' + '#'+currentAppointment)
$('#'+currentAppointment).addClass('selected');
}
您应该在id
使用时逃脱特殊的约束\\
,例如下面的示例。
希望这可以帮助。
console.log( $("#2015-11-30\\|1112\\|1").text() );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="2015-11-30|1112|1">Div text example</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句