0
當我把'homepage_game'-div懸停時,我想將一個id('data-gameid')傳遞給一個名爲game_get_info.php
的文件。如何傳遞一個id到一個文件
請問我該如何通過Javascript或jQuery完成此操作? TIA
這是PHP代碼:
<?php echo '
<div class="homepage_game home_tooltip" data-gameid="'.$game_cat_content['id'].'">
<div class="home_game_image">
<a href="'.$game_cat_content['url'].'">
<img class="home_thumb" src="'.$game_cat_content['image_url'].'" height="85" width="125" alt="'.$game_cat_content['name'].'"/>
</a>
</div>
</div>';
?>
這是JS/jQuery的代碼:
<script type="text/javascript">
$(document).ready(function() {
$('.tooltipstered').tooltipster('destroy');
$('.home_tooltip').tooltipster({
trigger: 'hover',
animation: 'fade',
animationDuration: 250,
delay: 1000,
onlyOne: true,
position: 'top',
contentAsHTML: true,
interactive: true,
theme: ['tooltipster-noir', 'tooltipster-noir-customized'],
content: 'Loading...',
functionBefore: function(instance, helper) {
var $origin = $(helper.origin);
if ($origin.data('loaded') !== true) {
$.post('<?php echo $setting['template_url']; ?>/sections/ajax/game_get_info.php, function(data) {
instance.content(data);
});
}
}
});
});
</script>
是你在頁面'game_get_info.php'? – FatalMerlin
你忘記了數據:。 – TGarrett