问题
How do I store a variable value in a rgb() ? I use this code which isn't working:
<script>
var R=200;
var colval="rgb(R,10,100)";
</script>
I want it to be like this:
<script>
var colval="rgb(200,10,100)";
</script>
but somehow it doesn't store R right , putting quotes around 200 or R isn't working either.
回答1:
I assume you're using JavaScript:
<script>
var R = 200;
var colval = "rgb(" + R + ",10,100)";
</script>
Results in colval = rgb(200,10,100)
来源:https://stackoverflow.com/questions/6088366/rgb-value-as-variable