2013-05-20 39 views

回答

2

您可以使用fetch tritium函数来获取要查找的元素中的类属性值并将其存储在变量中。

因此,考虑下面的HTML:

<html> 
    <head> 
    <title> Tritium Tester </title> 
    </head> 
    <body> 
    <div id="one" class="random"></div> 
    <div id="two"></div> 
    </body> 
</html> 

你可以写下面的氚:

html() { 
    $("/html/body") { 
    $class_name = fetch("./div[@id='one']/@class") 
    $("./div[@id='two']") { 
     add_class($class_name) 
    } 
    } 
} 

这里是一个活生生的例子链接:http://play.tritium.io/331dfa6d01a7dd52261a9eaf812bdc5c7fb8c293

相关问题