本文介绍了无法通过JQuery的ID在数据列表中找到元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是呈现的数据列表.似乎 $('#ctl00_ContentPlaceHolder1_ShowListing_DataList1 $ 3 $ 0 $$ enquire').click(function(){...} 无效,因为当我单击其中一个按钮(在DataList上)时旨在触发此功能,什么也没发生.
Below is a rendered Datalist. It seems that $('#ctl00_ContentPlaceHolder1_ShowListing_DataList1$3$0$enquire').click(function() { ... } does not work because when I click on one of the buttons (on the DataList) which are meant to trigger this function, nothing happens.
如何使用JQuery通过ID查找按钮?因此,基本上,如果单击DataList上的任何按钮,则应触发该功能.
How do I use JQuery to find the buttons by ID? So basically the function should be triggered if any of those buttons on DataList is clicked.
谢谢.
<table id="ctl00_ContentPlaceHolder1_ShowListing_DataList1" class="DataWebControlStyle"
style="visibility: visible;">
<tbody>
<tr>
<td class="RowStyle">
<div class="ListItemContainer">
<div class="EnquireButton">
<a class="activator" id="ctl00_ContentPlaceHolder1_ShowListing_DataList1$3$1$enquire">
</a>
</div>
</div>
</td>
</tr>
<tr>
<td class="RowStyle">
<div class="ListItemContainer">
<div class="EnquireButton">
<a class="activator" id="ctl00_ContentPlaceHolder1_ShowListing_DataList1$3$1$enquire">
</a>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(function() {
$('#ctl00_ContentPlaceHolder1_ShowListing_DataList1$3$0$enquire').click(function() {
$('#enquireOverlay').fadeIn('fast', function() {
$('#box').animate({ 'top': '160px' }, 500);
});
});
$('#boxclose').click(function() {
$('#box').animate({ 'top': '-200px' }, 500, function() {
$('#enquireOverlay').fadeOut('fast');
});
});
});
</script>
推荐答案
您应该使用live.
$("#boxclose").live("click", function() {
$('#box').animate({ 'top': '-200px' }, 500, function() {
$('#enquireOverlay').fadeOut('fast');
});
});
这篇关于无法通过JQuery的ID在数据列表中找到元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!