获取动态图像的边框颜色,然后打印 [英] Get the border color of a dynamic image then print it

查看:104
本文介绍了获取动态图像的边框颜色,然后打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在想,如果这样的动作是可能完成和需要哪种语言。

I have been wondering if such an action is possible to accomplish and which language would be required.

让我们假设我有一个图像与 border:1px solid#333

Let's assume I have a image with a border:1px solid #333

+------------+
|            |
|   image    | 
|   border   |
|   is       |
|   #333;    |
|            |
+------------+

页面被刷新,它会自动更新到另一个图像,它是一种不同的颜色。现在,是否可以以某种方式识别图像边框的1px(#333),然后打印该颜色?

Once the page is refreshed it automatically updates to another image where it is a different color. Now, is it possible to somehow identify the 1px of the image border(#333) and then print that color?

推荐答案

strong>您不需要使用jQuery来执行此操作。

You don't need to use jQuery to do this.

Pure JS方法使用 getComputedStyle() getPropertyValue()

Pure JS approach using getComputedStyle() and getPropertyValue().

jsFiddle example

el_style = window.getComputedStyle(document.getElementById('some_element'));
el_border_color = el_style.getPropertyValue('border-color');

alert(el_border_color); //"rgb(255,0,0)"

这篇关于获取动态图像的边框颜色,然后打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆