1

Is it possible add z-index via css method thought object:

jQuery('<div/>').css({
        z-index: 1000, 
        opacity: 0.7, 
        width: jQuery(window).width(), 
        height: jQuery(document).height(), 
        top:0, 
        left:0, 
        position: 'absolute'}).appendTo('body');

3 Answers 3

3
$("<div>").css({
    zIndex: 123
}).appendTo("body");

or

$("<div>").css({
    "z-index": 123
}).appendTo("body");

.css() doc:

... Also, jQuery can equally interpret the CSS and DOM formatting of multiple-word properties. For example, jQuery understands and returns the correct value for both .css({'background-color': ...}) and .css({backgroundColor: ...}).

Sign up to request clarification or add additional context in comments.

Comments

1

yes but you have to use apostrophes/quotation 'z-index marks:

jQuery('<div/>').css({
    "z-index": 1000, 
    opacity: 0.7, 
    width: jQuery(window).width(), 
    height: jQuery(document).height(), 
    top:0, 
    left:0, 
    position: 'absolute'}).appendTo('body');

Comments

1
jQuery('div').css('z-index',1000);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.