par
Aureusms » 14 avr. 2015, 08:36
Tu peux utiliser jQuery qui va drolement t'aider dans ton cas.
Imaginons une sortie de ta base de données comme celle ci :
//sortie sql : j'utilise la librairie mysqli en mode objet
while ($assoc = $mysqli->assoc()) :
?>
<a class="lien" href="<?php echo $assoc["href"]; ?>" id="<?php echo $assoc["id"]; ?>" identifiantTable="<?php echo $assoc["identifiantTable"]; ?>">
<?php echo $assoc["texteLien"]; ?>
</a>
<?php
endwhile;
Tu pourras récupérer les identifiants que j'ai mis en attribut "identifiantTable" via le javascript suivant :
Code : Tout sélectionner
$(document.body).on({
mouseenter : function () {
if (typeof($(this).attr('identifianttable')) != "undefined")
alert ($(this).attr('identifianttable'));
}
},'.lien');
Mais tu peux aussi utiliser l'attribut id ou tout autre attribut (c'est cela qu'est magique) :
Code : Tout sélectionner
$(document.body).on({
mouseenter : function () {
if (typeof($(this).attr('id')) != "undefined")
alert ($(this).attr('id'));
}
},'.lien');
ou
Code : Tout sélectionner
$(document.body).on({
mouseenter : function () {
if (typeof($(this).attr('href')) != "undefined")
alert ($(this).attr('href'));
}
},'.lien');
Tu peux utiliser jQuery qui va drolement t'aider dans ton cas.
Imaginons une sortie de ta base de données comme celle ci :
[php]//sortie sql : j'utilise la librairie mysqli en mode objet
while ($assoc = $mysqli->assoc()) :
?>
<a class="lien" href="<?php echo $assoc["href"]; ?>" id="<?php echo $assoc["id"]; ?>" identifiantTable="<?php echo $assoc["identifiantTable"]; ?>">
<?php echo $assoc["texteLien"]; ?>
</a>
<?php
endwhile;[/php]
Tu pourras récupérer les identifiants que j'ai mis en attribut "identifiantTable" via le javascript suivant :
[code]$(document.body).on({
mouseenter : function () {
if (typeof($(this).attr('identifianttable')) != "undefined")
alert ($(this).attr('identifianttable'));
}
},'.lien');[/code]
Mais tu peux aussi utiliser l'attribut id ou tout autre attribut (c'est cela qu'est magique) :
[code]$(document.body).on({
mouseenter : function () {
if (typeof($(this).attr('id')) != "undefined")
alert ($(this).attr('id'));
}
},'.lien');[/code]
ou
[code]$(document.body).on({
mouseenter : function () {
if (typeof($(this).attr('href')) != "undefined")
alert ($(this).attr('href'));
}
},'.lien');[/code]