I'm not sure if this is possible, but I'm trying to take the value of $css_color and set it as the hex value in the div. Also with the $x and $y values.
Essentially, I'm attempting to grab the $x$y info and the hex code value from an image and matching it to an array of color values I have in formatted_colors.js then rebuilding the "image" as divs with the background color as testing.
Example of my formatted_colors.js array var colors = []; colors["000000"] = "black"; colors["100000"] = "black";
Here is a snippet:
<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script src="formatted_colors.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
//iterate through pixels and match rounded color to array in formatted_colors.js
<div class="rounded_color" hex="<?php $css_color ?>" xy="<?php $x.$y ?>"</div>
<div id="<?php $x.$y ?>"></div>
$(document).ready(function() {
$(".rounded_color").each(function(){
var google_color = getColor($(this).attr("hex"));
$('#'+$(this).attr("id")).html(google_color);
$('#'+开发者_JS百科$(this).attr("id")).css('background-color:', google_color);
})
// get name of color function from formatted_colors.js
function getColor(target_color){
if (colors[target_color] == undefined) { // not found
return "no match";
} else {
return colors[target_color];
}
} // end getColor function
)} // end ready function
</script>
And here is my entire code: http://pastebin.com/A4tMsn2C
Try <?php echo $x.$y ?>
instead (and similar for your other blocks). Or, if you've got shorttags enabled <?= $x . $y ?>
. Your version is simply doing a concatentation and throwing out the results. You need to echo out the results of whatever you're doing inside the PHP block.
精彩评论