SyntaxError: identifier starts immediately after numeric literal
来源:互联网 发布:sql alter 编辑:程序博客网 时间:2024/05/22 10:27
在用javascript时,当你使用一个字符传作为函数的参数常常会看到语法错误,在firebug下会报SyntaxError: identifier starts immediately after numeric literal ,当然在google下提示就不准确了。
错误原因是:标识符以数字开头
下面直接看例子吧:
$(function(){
var str = "509edbe9-2914-431f-9128-97d368b7da0b";
//错误的写法
var html = '<button class="button" id="ensure" onclick="test(str)">确定</button>';//把字符串作为参数传给函数,直接报错
//正确的写法
var html = '<button class="button" id="ensure" onclick="test(\''+str+'\')">确定</button>';//正确执行,注意第一个\后是两个单引号
$("#dd").append(html);
});
function test(id){
console.log(id);
}
<div id="dd"></div>
0 0
- SyntaxError: identifier starts immediately after numeric literal
- SyntaxError: identifier starts immediately after numeric literal
- SyntaxError: identifier starts immediately after numeric literal
- SyntaxError: identifier starts immediately after numeric literal
- SyntaxError:identifier starts immediately after numeric literal
- SyntaxError: identifier starts immediately after numeric literal
- SyntaxError:identifier starts immediately after numeric literal
- js SyntaxError: identifier starts immediately after numeric literal
- SyntaxError: identifier starts immediately after numeric literal错误解决办法
- 【解决】SyntaxError: identifier starts immediately after numeric literal
- SyntaxError: identifier starts immediately after numeric literal错误解决办法
- identifier starts immediately after numeric literal
- identifier starts immediately after numeric literal
- SyntaxError: identifier starts immediately after numeric literal数字后面不能直接跟标识符
- 错误记录(10)SyntaxError: identifier starts immediately after numeric literal
- identifier starts immediately after numeric literal 意思是语法错误
- 今天遇到: identifier starts immediately after numeric literal
- Syidentifier starts immediately after numeric literal
- XCode如何添加自定义代码片段
- Android framework——Activity的启动和创建
- 函数构造库
- jQuery点滴细节 保证代码安全
- 查找算法总结——面试(一)
- SyntaxError: identifier starts immediately after numeric literal
- 回归教育本质 培养实用型人才——记杭州年代专修学校
- Xenomai 2.6.4 发布, 支持 Atmel SAMA5D3
- 量初始化列表
- cocos2dx 添加 libiconv.lib 解决 字符转换问题
- uva 1519 Dictionary Size
- 渍综姿嘴着妆转咨谆字钻奏字走足紫纵撞
- 奏爪孜注综妆淄谆卓醉籽撞组追状阻琢族
- opencv中RGB转HSV