如何获取元素的背景颜色代码?
HTML
<div style="background-color:#f5b405"></div>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$(this).css("background-color");
Run Code Online (Sandbox Code Playgroud)
结果
rgb(245, 180, 5)
Run Code Online (Sandbox Code Playgroud)
我想要的是
#f5b405
Run Code Online (Sandbox Code Playgroud) 我正在尝试获取当前日期加7天才能显示.
示例:今天是2012年8月16日,所以这个php片段将在2012年8月23日输出.
$date = strtotime($date);
$date = strtotime("+7 day", $date);
echo date('M d, Y', $date);
Run Code Online (Sandbox Code Playgroud)
现在,我得到了:1970年1月8日.我错过了什么?
我正在使用Java版本的Google App Engine.
我想创建一个函数,可以接收许多类型的对象作为参数.我想打印出对象的成员变量.每个对象可能不同,并且该功能必须适用于所有对象.我必须使用反射吗?如果是这样,我需要编写什么样的代码?
public class dataOrganization {
private String name;
private String contact;
private PostalAddress address;
public dataOrganization(){}
}
public int getObject(Object obj){
// This function prints out the name of every
// member of the object, the type and the value
// In this example, it would print out "name - String - null",
// "contact - String - null" and "address - PostalAddress - null"
}
Run Code Online (Sandbox Code Playgroud)
我该如何编写函数getObject?
我有一个库存标准类调用GeoRssParserDelegate,需要进行测试.
在我的快速单元测试中我得到了这个:
func testParser()
{
var bundle = NSBundle(forClass:GeoRssParserTest.classForKeyedArchiver())
var path = bundle.pathForResource("test", ofType: "xml")
let data = NSData.dataWithContentsOfFile(path, options: NSDataReadingOptions.DataReadingMapped, error: nil)
let xmlParser = NSXMLParser(data:data)
let delegate = GeoRssParserDelegate() <-- Compiler fails here
var bStatus = xmlParser.parse()
XCTAssertTrue(bStatus, "Parse failed", file: __FILE__, line: __LINE__)
}
Run Code Online (Sandbox Code Playgroud)
编译器在上面突出显示的行上失败.编译器错误是使用未解析的标识符GeorRssParserDelegate
该类确实存在并且与产品本身一起构建.有什么需要特别的吗?
我正在使用slf4j 1.6.2 api jar(也尝试使用1.6.1) - logback版本是0.9.29(核心和经典).我在ubuntu上使用jdk1.6.我收到的例外情况将在下面复制.
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.helpers.MessageFormatter.arrayFormat(Ljava/lang/String;[Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple;
at ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:112)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:471)
at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:427)
at ch.qos.logback.classic.Logger.info(Logger.java:631)
Run Code Online (Sandbox Code Playgroud)
我也收到一条抱怨slf4j绑定不匹配的消息.
"SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11]"
Run Code Online (Sandbox Code Playgroud) 我是Clojure的新手并且发现当我使用列表理解在clojure中循环这个向量时,我最后得到了一些nils.
(def myVec [1,2,3])
user=> (for [x myVec] (println x))
(1
2
3
nil nil nil)
Run Code Online (Sandbox Code Playgroud)
我使用相同的东西 map
user=> (map println myVec)
(1
2
3
nil nil nil)
Run Code Online (Sandbox Code Playgroud)
是什么原因导致在这些情况下打印nill?
我正在尝试在Swift中创建一个元组数组,但是很难:
var fun: (num1: Int, num2: Int)[] = (num1: Int, num2: Int)[]()
Run Code Online (Sandbox Code Playgroud)
以上导致编译器错误.
为什么那么错?以下工作正常:
var foo: Int[] = Int[]()
Run Code Online (Sandbox Code Playgroud) 我在我的一个流浪项目中使用木偶作为我的供应者.我正在尝试为自定义bash_profile添加模块.
在module_path对木偶被设置为:
puppet.module_path = "puppet/modules"
Run Code Online (Sandbox Code Playgroud)
我的bash_profile模块的类看起来像这样:
class bash_profile
{
file
{
"/home/vagrant/bash_profile":
ensure => present,
source => "puppet:///modules/bash_profile/files/bash_profile"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的木偶结构的文件结构:
puppet
| manifests
| | phpbase.pp // my main manifest file that has includes for modules
| modules
| | bash_profile
| | | files
| | | | bash_profile // the actual bash_profile file I want to ensure is present on my VM
| | | manifests
| | | | init.pp // the init file …Run Code Online (Sandbox Code Playgroud) 我有一个返回的方法List<Map<String,Object>>.
如何迭代列表 List<Map<String,Object>>?