使用同一页面中的onClick函数从链接获取值

时间:2022-11-27 18:23:09

this is the javascript code

这是javascript代码

<script type="text/javascript">
    function divHDVisible(){
        var div = document.getElementById('linkHD');
        div.style.visibility = 'visible';
    }
</script>

and this is the jsp code

这是jsp代码

<font size="-2">
    <a href="#" onclick="divHDVisible()"><%=dataJobs.getID_Harware_Use()%></a>
</font>
<div class="row" id="linkHD" style="visibility: hidden;">Success</div>

what i want is get the value of <%=dataJobs.getID_Harware_Use()%> inside the div(div id=linkHD) can any one help me?

我想要的是得到div里面的<%= dataJobs.getID_Harware_Use()%>的值(div id = linkHD)可以帮助我吗?

1 个解决方案

#1


0  

Try this:

function divHDVisible(elem) {
  var div = document.getElementById('linkHD');
  div.style.visibility = 'visible';
  div.innerHTML = elem.innerHTML;
}
<font size="-2"><a href="#" onclick="divHDVisible(this)"><%=dataJobs.getID_Harware_Use()%></a></font>

<div class="row" id="linkHD" style="visibility: hidden;">Success</div>

#1


0  

Try this:

function divHDVisible(elem) {
  var div = document.getElementById('linkHD');
  div.style.visibility = 'visible';
  div.innerHTML = elem.innerHTML;
}
<font size="-2"><a href="#" onclick="divHDVisible(this)"><%=dataJobs.getID_Harware_Use()%></a></font>

<div class="row" id="linkHD" style="visibility: hidden;">Success</div>