bui quang huy
bui quang huy

Reputation: 153

JQuery .width() for this element

How can I get width of element which I css. My code:

$('a').css({'left':-$(this).width()/2})

Upvotes: 0

Views: 39

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388436

You can use a callback as the property value which can return the actual style value

$('a').css({
    'left': function () {
        return -$(this).width() / 2
    }
})

Upvotes: 2

Related Questions