I
I
Ilyusha Prokopiev2016-01-31 02:39:00
JavaScript
Ilyusha Prokopiev, 2016-01-31 02:39:00

How to cut part of a string with jQuery?

I get the shadow variable

var shadow = String($(".pageblocks_now").css("box-shadow"));

The variable receives, for example, rgb(255, 150, 117) 0px 0px 5px 2px
It is only required to get the color. How to solve this problem with jQuery?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2016-01-31
@iliapro

javascript.ru/basic/regular-expression+
/^rgb\((.*)\)/ $1 will be (without brackets) if I'm not buggy at night....
var str = "rgb(255, 150, 117) 0px 0px 5px 2px";
var subresult = str.match( /^rgb\((.*)\)/)/ );
varresult = subresult[1];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question