`
JoneSong
  • 浏览: 1443 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
社区版块
存档分类
最新评论

Uncaught Error: Syntax error, unrecognized expression: "#SWCX[pstid]

阅读更多
		var data = {"data":[{"pstid":100001,"id":"SWCX","pstx":670,"psty":109},{"pstid":100002,"id":"FWCX","pstx":830,"psty":269},{"pstid":100003,"id":"BWCX","pstx":510,"psty":189},{"pstid":100004,"id":"NBTX","pstx":192,"psty":109},{"pstid":100005,"id":"LXFS","pstx":350,"psty":269},{"pstid":1000016,"id":"CYXZ","pstx":192,"psty":29},{"pstid":100006,"id":"SWCX2","pstx":830,"psty":109},{"pstid":100007,"id":"SWCX1","pstx":510,"psty":269},{"pstid":1000015,"id":"SWCX3","pstx":350,"psty":29},{"pstid":100008,"id":"SWCX4","pstx":350,"psty":109},{"pstid":100009,"id":"LXFS2","pstx":670,"psty":189},{"pstid":100010,"id":"CYXZ2","pstx":350,"psty":189},{"pstid":100011,"id":"SWCX5","pstx":192,"psty":189},{"pstid":100012,"id":"SWCX6","pstx":510,"psty":29},{"pstid":100013,"id":"SWCX7","pstx":670,"psty":29},{"pstid":100014,"id":"SWCX8","pstx":830,"psty":29},{"pstid":100017,"id":"FWCX9","pstx":830,"psty":189},{"pstid":100018,"id":"FWCX8","pstx":510,"psty":109}]};
		var obj = eval(data).data;
		
		function init(){
			console.log(obj.length);
			for(var i=0;i<obj.length;i++){
				//alert('"#'+ obj[i].id + '[pstid='+obj[i].pstid+']"');
				//$('"#'+ obj[i].id + '[pstid='+obj[i].pstid+']"').parent().css({"position":"absolute"});
				[color=red]$("#" + obj[i].id + '[pstid='+obj[i].pstid+']')[/color].css({"padding-top":"0px"});
				$("#" + obj[i].id + '[pstid='+obj[i].pstid+']').parent().offset({top:(parseInt(obj[i].psty)) ,left:(parseInt(obj[i].pstx))});
			}
		}

以上代码报:Uncaught Error: Syntax error, unrecognized expression: "#SWCX[pstid]
解决办法:$(("#" + obj[i].id + '[pstid='+obj[i].pstid+']')),在#id外边再加一层括号即$((#id))
分享到:
评论
Global site tag (gtag.js) - Google Analytics