[英]Get id of div tags using hidden field
I have six div tags in my project and a hidden field. 我的项目中有六个div标签,一个隐藏字段。 On mouse-over of this each div I want to get the value of div using hidden field.
将鼠标悬停在每个div上时,我想使用隐藏字段获取div的值。 Is there a way out for this?
有没有解决的办法?
Below is my code: 下面是我的代码:
<div class="item user">
<h2>qhse</h2>
<div id='qhse' class="qhse" runat="server" >
</div>
</div>
<div class="item home">
<a href="#" class="icon"> </a>
<h2>policies</h2>
<div id='hexa' class="hexa" runat="server" >
</div>
</div>
<div class="item shop">
<a href="#" class="icon"> </a>
<h2>procedures</h2>
<div id='policies' class="policies" runat="server">
</div>
</div >
<div class="item camera">
<a href="#" class="icon"></a>
<h2>certificates</h2>
<div id='certificates' class="certificates" runat="server" >
</div>
</div >
<div class="item fav">
<a href="#" class="icon"></a>
<h2>forms</h2>
<div id='forms' class="forms" runat="server" >
</div>
</div >
<div class="item last">
<a href="#" class="icon"></a>
<h2>hexa</h2>
<div id='procedures' class="procedures" runat="server" >
</div>
</div >
</div>
I wish to get the id of each div in hidden field using javascript. 我希望使用javascript获取隐藏字段中每个div的ID。
Javascript Java脚本
$(function () {
$('#nav > div').hover(function () {
var $this = $(this);
$this.find('div').stop().animate({
document.getElementById("<%= hdnSelected.ClientID %>").value = "Policies";
});
But doing this method I am getting id of only one div. 但是用这种方法我只能得到一个div的id。 I need to get id's of all div's.
我需要获取所有div的ID。
Thanks 谢谢
Try this 尝试这个
$(function(){
var field = $('#<%= hdnSelected.ClientID %>');
$('#nav').on('mouseover', '.item > div[id]', function() {
field.val(this.id);
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.