Js 抱错:::SyntaxError: identifier starts immediately after numeric literal
SyntaxError: identifier starts immediately after numeric literal
今天写了个onclick()方法,有这样的一个变量4028b88161c881ff0161c88b80dc0002
需要把这个变量值传入方法内,但始终不成功:
我发现直接将 var aa =4028b88161c881ff0161c88b80dc0002 ;js是抱错的
解决如下:
参考:http://blog.csdn.net/shalousun/article/details/39995443
https://stackoverflow.com/questions/14966133/syntaxerror-identifier-starts-immediately-after-numeric-literal-in-firebug
$(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>
Js 抱错:::SyntaxError: identifier starts immediately after numeric literal的更多相关文章
- E QUERY [main] SyntaxError: identifier starts immediately after numeric literal mongodb mapReduce 异常分析 集合命名规范
异常信息 repl_test:PRIMARY> db.0917order_totals_b.find()2018-09-28T15:13:03.992+0800 E QUERY [main] S ...
- 错误:SyntaxError: identifier starts immediately after numeric literal
转载:http://blog.csdn.net/shalousun/article/details/39995443在用JavaScript时,当你使用一个字符传作为函数的参数常常会看到语法错误,在f ...
- js 传参报错 参数含有数字、字母组合的字符串SyntaxError: identifier starts immediately after numeric literal
报错的意思是标识符以数字开头,这是因为js是弱类型的语言当发现第一个数字是就自动转化为数字类型的但是其中还含有字符所以报了错,‘ 报错的原因是因为我们想传的字符串,但是js却当成数字,所以需要给传的参 ...
- SyntaxError:identifier starts immediately after numeric literal
1.错误描写叙述 2.错误原因 因为在改动方法传參的过程,须要传个id,可是这个id是字符串类型,传入的是数值型 3.解决的方法 在传參时,须要加入"",变成字符串类型 User. ...
- 使用onclick报SyntaxError: identifier starts immediately after numeric literal
少了‘’ 错误 onclick="onlineWatch(${row.title})" 正确 onclick="onlineWatch('${row.title}')&q ...
- jQuery 事件函数传参异常identifier starts immediately after numeric literal
问题情境: var arr=[aabbcc,112233]; var html = ""; for(var i =0;i<arr.length;i++){ html += ' ...
- javascript中出现identifier starts immediately after numeric literal错误原因以及解决方法
javascript遇到参数是字符型和数字型组合的参数就会出现这种错误,例如alert(1);可以正確輸出alert(str);就會報錯alert("str");可以正確輸出.
- Node.js启动服务报错SyntaxError: Unexpected token import
启动服务报错如下: Last login: Wed Nov :: on ttys000 localhost:~ sipeng$ cd /Users/sipeng/Desktop/彭思/2017年学习/ ...
- chrome js报错Uncaught SyntaxError: Unexpected string
个人博客 地址:http://www.wenhaofan.com/article/20180912123136 js报错,最后发现是$(function(){})这部分()不完整 $(function ...
随机推荐
- 10. 修改端口号【从零开始学Spring Boot】
转载:http://blog.csdn.net/linxingliang/article/details/51637017 spring boot 默认端口是8080,如果想要进行更改的话,只需要修改 ...
- perl学习笔记三
子程序 定义子程序(可以在程序的任意位置) 关键字sub.子程序名(不包含与号)以及用花括号封闭起来的代码快. 如:sub marine{ $n+=1; print "hello,sailo ...
- PHP使用mysqli连接MySQL数据库
使用mysqli函数库连接MySQL,支持面向对象和面向过程两种方式: 1.面向对象的使用方式 建立一个连接 $db = new mysqli('localhost', 'root', '123456 ...
- Picasso自定义缓存目录
项目做完终于有点自己的时间了,就想看点源码涨涨姿势,那就看看Picasso这个牛逼哄哄的图片加载框架吧,当然这个也是自己最喜欢的图片加载框架. 实际项目中可能有需求自己定制图片的缓存目录,那么就需要自 ...
- MSSQL站库分离情况的渗透思路
本文转自:http://bbs.blackbap.org/thread-6203-1-2.html 1. 服务器属内网环境,站库分离,通过web.config找到数据库服务库SA帐号密码,成功添加用户 ...
- Android学习(十) SQLite 基于内置函数的操作方式
main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns ...
- Activity返回数据给上一个活动
1.在A这个Activity中以startActivityForResult(intent, requestCode)启动B这个Activity 2.在B这个Activity中setResult(re ...
- Mysql-Proxy实现mysql读写分离、负载均衡 (转)
在mysql中实现读写分离.负载均衡,用Mysql-Proxy是很容易的事,不过大型处理对于性能方面还有待提高,主要配置步骤如下: 1.1. mysql-proxy安装 MySQL Proxy就是这么 ...
- MySQL_常用SQL语句
1.按小时统计的语句 select concat(date_format(gmt_create, "%Y-%m-%d %k:00~"), hour(gmt_create)+1, & ...
- linux上复制行到另一个文件
1.复制3行到5行数据到ab.sh文件,不覆盖ab.sh文件中的已有内容 :3,5w>>ab.sh 2.复制3行到5行数据到ab.sh文件,覆盖ab.sh文件中的已有内容 :3,5w!ab ...