开发者

What's wrong with jQuery, .css and z-index - i.e. find the error in the following code?

What's wrong with this?

    $("#tag_square").appendTo('#edit-area img').css({ position: "relative", left: "100px", top: "10px", z-index: "2"});

Everything up to the z-index works perfectly. Once I include the Z-index though, I get an 'uncaught S开发者_JS百科yntaxError - Unexpected Token' in the Javascript console.

What gives?

Any ideas on what I am doing wrong and how to fix it?


You might find it's the - in z-index. Try using camelCase to see if it makes a difference:

$("#tag_square").appendTo('#edit-area img').css({ position: "relative", left: "100px", top: "10px", zIndex: "2"});

Or simply quote the property name, either using single ('z-index') or double ("z-index") quotes.


You can't use dash in javascript variable names. Try changing z-index to a string ('z-index')


Try "z-index": "2"?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜