$(selector).click() passage de variables
Je voudrais remplacer " selector " par un paramètre sur le on click du #selector, en fait ce serait un truc style ( onclick=param=id_du_selector ) et récupérer param dans $("#selector").on("click",function(){, ou selector serait param
pouvez vous m'aider ?
par avance merci ;)
amicalement, Rick
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <script>
$(document).ready(function(){
$("#selector").on("click",function(){
$("#selector").fadeIn();
$("#selector").css({top: 0, left: 0, position:'absolute'});
$("#selector").css('z-index', 2);
});
$(".btn1").click(function(){
$("#selector").fadeOut();
});
});
</script>
<map ...>
<area coords="242,763,71" shape="circ" href="#" Id="selector" alt="Stan" target="_self" onmouseover="window.status='Stan Lee ?';return true;" onclick="param=$this.id"> |
RE : $(selector).click() passage de variables
Re bonjour, ben ça marche pas :(
ceci dit ...
Code:
1 2 3 4 5 6 7
|
<script>
$(document).ready(function(){
$(".Area").on("click",function(GetId){
alert('"#' + GetId.target.id + '"'); // fonctionne, resultat "#MonDivId" :)
$('"#' + GetId.target.id + '"').fadeIn(); // ne fonctionne pas :(
$('"#' + GetId.target.id + '"').css({top: 0, left: 0, position:'absolute'}); // ne fonctionne pas :( |
Une idée ?
Merci de votre attention
Amicalement Rick
RE : $(selector).click() passage de variables
Bonjour,
en gras ce que je voudrais obtenir dynamiquement en fonction de l'area clicqué
Merci
Amicalement, Rick ;)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<script>
$(document).ready(function(){
$(".Area").on("click",function(){
$("#StanDiv").fadeIn().css({top: 0, left: 0, position:'absolute'});
});
$(".btn1").click(function(){
$("#StanDiv").fadeOut();
});
});
</script>
</head>
<body>
<div>
<img id="Avengers" class="Avengers" src="img/Avengers.png" usemap="#Map">
<map name="Map">
<area coords="242,763,71" shape="circ" href="#" Id="StanLee" alt="Stan Lee" class="Area" target="_self" onmouseover="window.status='Stan Lee ?';return true;">
<area coords="252,478,373,516" shape="rect" href="#" id="NickFury" alt="Nick Fury" class="Area" target="_self" onmouseover="window.status='Nick Fury ?';return true;"> |
RE : $(selector).click() passage de variables
Bonjour,
Bon, je laisse tomber :(
Mais c'est pas grave j'ai une autre solution ;)
Merci pour tout ;)
Amicalement Rick
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<script>
$(document).ready(function(){
$(".Area").on("click",function(e){
e.preventDefault();
// récup. de l'ID cible
const elem = e.target;
const idCible = '"#'+elem.id+'"';
alert(idCible); // fonctionne ;)
$(idCible).fadeIn().css({top: 0, left: 0, position:'absolute'}); // ne fonctionne plus :(
$("#HeroeImg").append("<b>Appended text</b>");
$("#HeroeTxt").append("<b>Appended text</b>");
});
$(".btn1").click(function(e){
e.preventDefault();
// récup. de l'ID cible
const elem = e.target;
const idCible = '"#'+elem.id+'"';
alert(idCible);
$(idCible).fadeOut();
});
});
</script> |
RE : $(selector).click() passage de variables
je vous donne
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <script>
$(document).ready(function(){
$(".Area").on("click",function(GetId){
$("#StanHeader").empty();
$("#HeroeImg").empty();
$("#HeroeTxt").empty();
GetId.preventDefault();
// récup. de l'ID cible
const elem = GetId.target;
const IdCible = '"' + elem.id + '"';
$("#StanDiv").fadeIn().css({top: 0, left: 0, position:'absolute'});
$("#StanHeader").append('<b>[php] ' + IdCible + '</b>');
$("#HeroeImg").append("<b>[php]</b>");
$("#HeroeTxt").append("<b>[php]</b>");
// ...
});
$(".btn1").click(function(){
$("#StanHeader").empty();
$("#StanDiv").fadeOut();
});
});
</script> |
ma solution :)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| <!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>The Avengers fan Page</title>
<link rel="stylesheet" href="">
<script src=""></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<style>
.Avengers{
top: 0;
left:0;
Width: 100%;
height: auto;
}
#StanDiv {
background-color: white;
display: none;
width: 80%;
margin-left: 10%;
margin-top: 5%;
border-style: outset;
border-width: thick;
border-color: silver;
border-radius: 5px;
padding: 5px;
}
#HeroeImg{
width: 30%;
height: auto;
border: 1px solid black;
float: left;
}
#HeroeTxt{
width: 68%;
height: auto;
border: 1px solid black;
float: right;
}
</style> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <div>
<img id="Avengers" class="Avengers" src="img/Avengers.png" usemap="#Map">
<map name="Map">
<area coords="242,763,71" shape="circ" href="#" Id="Stan Lee" alt="Stan Lee" class="Area" target="_self" onmouseover="window.status='Stan Lee ?';return true;">
<area coords="252,478,373,516" shape="rect" href="#" id="Nick Fury" class="Area" alt="Nick Fury" target="_self" onmouseover="window.status='Nick Fury ?';return true;">...
<div id="StanDiv">
<span Id="StanHeader" style="width: 95%;"></span><a href="#" class="btn1"><img id="retour" src="img/close.png" style="float: right;"><a>
<br>
<br>
<div id="HeroeImg"></div>
<div id="HeroeTxt"></div>
<br>
<br>
<span id="StanFooter"><a href="#" class="btn1"><img id="retour" src="img/close.png" style="float: right;"><a></span>
</div> |
c'est sûrement tordu :D, mais ça marche :D
Encore une fois merci
Amicalement Rick