我已经看了好几天了,完全被卡住了。我正在处理的页面如下所示:
@GetMapping("/hello")
public void hello(@RequestParam int id){
Span span = tracer.buildSpan("Count" + id).withTag("Number",id).start();
try(Scope scope = tracer.activateSpan(span)){
System.out.println("Printing 1st thing");
hello2("Hello1");
}finally {
span.finish();
}
}
private void hello2(String s){
Span span = tracer.buildSpan("2nd Method").withTag("Name",s).start();
try(Scope scope = tracer.activateSpan(span)){
System.out.println("Printing 2nd Hello");
}finally {
span.finish();
}
}
我设置的自定义变量如下所示:
<div class="field--item">
<span class="file file--mime-application-pdf file--application-pdf icon-before">
<div class="file-info text-center--mobile"><span class="file-icon"><span class="icon glyphicon glyphicon-file text-primary" aria-hidden="true"></span></span><div class="file-wrapper"><span class="file-name">17840.pdf</span><span class="file-size">94.35 KB</span></div></div>
<span class="file-link"><a href="/dashboard/download/17840/122526" class="resource-button" resource-name="Kennedy's actions in Vietnam in 1962" resource-file-id="122526" resource-file-type="PDF" resource-subject="History" resource-category="">Download</a>
</span></span></div>
我真正想做的是设置一个变量,当单击“下载”按钮时,该变量会引入资源名称。我知道要单独设置实际的点击跟踪等,但我无法让此函数将任何内容传递给“已定义”以外的变量。
对正确方向的任何帮助或点头都将非常感谢。谢谢!
答案 0 :(得分:0)
也许你可以使用点击事件:
a
答案 1 :(得分:0)
尝试删除最后的 text()
函数:
function getAttribute() {
return document.getElementsByClassName('resource-button')[0].getAttribute('resource-name');
}
console.log(getAttribute());
<div class="field--item">
<span class="file file--mime-application-pdf file--application-pdf icon-before">
<div class="file-info text-center--mobile"><span class="file-icon"><span class="icon glyphicon glyphicon-file text-primary" aria-hidden="true"></span></span><div class="file-wrapper"><span class="file-name">17840.pdf</span><span class="file-size">94.35 KB</span></div></div>
<span class="file-link"><a href="/dashboard/download/17840/122526" class="resource-button" resource-name="Kennedy's actions in Vietnam in 1962" resource-file-id="122526" resource-file-type="PDF" resource-subject="History" resource-category="">Download</a>
</span></span></div>