replaceWith is not a function
Bonjour ^^
Je suis en train de me faire un script avec jquery pour redimensionner les image plus grande qu'un div (pour éviter les débordement) le redimensionnement fonctionne, maintenant que je cherche à rendre cliquable l'image pour les afficher en taille normal j'obtiens une erreur
Code:
$j(this).replaceWith is not a function
html :
Code:
<div id="main"><img class="redim "src="photos/paysage-bleu.jpg" /></div>
Jquery :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| $j(document).ready(function() {
var mainWidth = $j('#main').width();
console.log( "#main Width("+mainWidth+")");
$j('#main img').each(function(){
var imgSRC = $j(this).attr("src");
var imgOriWidth = $j(this).width();
var redimWidth = $j(this).width(mainWidth-"50");
var imgWidth = $j(this).width();
console.log(imgSRC +" current width :"+imgWidth+"(original :"+imgOriWidth+")");
$j(this).replaceWith('<a href="'+imgSRC+'" title="Afficher DA image"><img style="width: '+redimWidth+'px;" src="'+imgSRC+'" /></a>');
});
}); |
Console
Code:
1 2 3 4
| #main Width(950)
photos/paysage-bleu.jpg current width :900(original :1920)
$j(this).replaceWith is not a function
[Break on this error] $j(this).replaceWith('<a href="'+imgSR...Width+'px;" src="'+imgSRC+'" /></a>'); |
Pourtant replacethis est bien une fonction jquery :\
J'utilise jquery-1.1.3.1