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"
?
精彩评论