How to get just one parameter in 'clip' CSS property using JQuery? [duplicate]


Tags: javascript,jquery,html,css

Problem :

This question already has an answer here:

this is a really short question, but needed:

I need to get just one parameter of this 'clip' CSS property

clip:rect(260px, 160px, 260px, 0px);

in this case I'd need to get the '260px' parameter only and set it equal to a variable 'x', how do I get that one only?

Remember I'm using Jquery :)



Solution :

You'll need to do some string manipulation on the property:

var clip = $("#bulb_light").css("clip"); // rect(260px 160px 260px 0px)
var clipTop = clip.split(' ')[0].replace("rect(", ""); // 260px

    CSS Howto..

    php- How to strip CSS in the text

    How to truncate paragragh lines in css [duplicate]

    How to make text wrap when resizing in a inline div, without the div moving onto a new line first?

    how to have spacing html/css

    How to control size of list-style-type disc in CSS?

    How to apply !important using .css()?

    How to debug the different behavior of the same browser on the different platforms?

    How can I exclude some images from being preloaded

    CSS: How to produce rounded boxed list

    How to fake width animation with CSS transform?

    How to center SVG within its container?

    How to top-align smaller inline-block elements next to larger elements?

    How to embedded all resources(css,js,images) into one single html file?

    Showcase the first n-items in a bootstrap grid

    How to develop a webpage with Bootstrap [closed]

    How to change color of element when hovering over another element?

    How to indent input controls for a nested HTML list using CSS to a single column

    How to hide main menu while showing sub-menu in css

    CSS Dropdown menu - How to add thumbnails

    How to create a lightbox like this [closed]

    How to change focus color when input is filled in with required attribute javascript/html/css

    How to justify short text inside fill fixed width parent with CSS?

    How to scale div from jquery css

    How to accomplish this layout with CSS and HTML?

    How can I change the size of this box? (CSS)

    How to style a GWT CaptionPanel?

    How to make irregular CSS border

    How to rotate element to left and right based on mouse movement using jQuery & CSS

    how to show section of a CSS sprite within a set position on the whole html body

    How to make a span tag wider with an alphabet inside?