很可能是一个简单的解决方案,但请原谅我在编程领域的早期学习曲线,并将jquery与php结合使用。我能够轻松地从数据库中检索信息并在屏幕上显示。但是,我希望能够隐藏从数据库中检索到的某些元素,并在页面上用php写出并在点击事件中显示它们。我可以在网站的其他部分轻松地执行此操作,这些部分未使用$ .post进行检索。一旦我使用$ .post和ajax从数据库中检索信息,是否有适用于jQuery的某些规则?
下面的php:
<?php echo "
<div class='phone_tracking customCall separation'>
<h3>Phone Tracking</h3>
<a class='showCustomDatePhone' href='#customDate_individualPhone'>View & Listen to Individual Phone Leads >></a>
<table>
<tr class='tableHead'>
<td>Date</td>
<td>Traffic+ Calls</td>
<td>New Vehicle Calls</td>
<td>Used Vehicle Calls</td>
<td>Service Calls</td>
<td class='totalTally'>Total Calls</td>
</tr>
<tr>
<td>`$valueRetrieved` - `$valueRetrieved2`</td>
<td>$customDateTrafficPlusTally</td>
<td>$customDateNewVehicleTally</td>
<td>$customDateUsedVehicleTally</td>
<td>$customDateServiceTally</td>
<td>$customDateTally</td>
</tr>
</table>
<div id='customDate_individualPhone'>
<h4>All Individual Phone Calls For `$valueRetrieved` - `$valueRetrieved2`</h4>
<table>
<tr>
<td>Date</td>
<td>Ad Source</td>
<td>Caller Phone Number</td>
<td>Tracking Phone Number</td>
<td>Target Phone Number</td>
<td>Call Duration (in seconds)</td>
<td>Result of Phone Call</td>
<td>Call Listen Link</td>
</tr> " . $showTheCustomDatePhoneTable ."
</table>
</div>
</div>
"; ?>
下面的jQuery:
$('#customDate_individualPhone').hide();
$('.showCustomDatePhone').click(function(){
var txt = $("#customDate_individualPhone").is(':visible') ? 'View & Listen to Individual Phone Leads >>' : '<< Hide Individual Phone Leads';
$(".showCustomDatePhone").text(txt);
$('#customDate_individualPhone').toggle();
});
检索数据的ajax(如果有帮助的话)
$('#getDateRange').on('click', function(){
var startDate = $('#dateStart').val();
var endDate = $('#dateEnd').val();
if ($.trim(startDate) != '') {
$.post('../../includes/dateRangeWhitePlainsNissan.php', {dateStart: startDate, dateEnd: endDate}, function(data){
$('#fromDatabase').html(data);
});
}
});
我对编程仍然很陌生,所以非常感谢你的帮助!感谢
答案 0 :(得分:0)
您需要使用回调重新初始化点击功能,或将其转换为使用on()。
$('.showCustomDatePhone').on('click', function(){});