J'ai un problème si je veux définir la hauteur et la largeur de l'image à l'intérieur de la div en utilisant uniquement Javascript et JQuery.Définir la hauteur et la largeur de l'image à l'intérieur div en utilisant javascript et jquery
Voici mon code:
<div class="myGallery">
<img class="replaced" src="myimage.jpg" style="display: inline;">
</div>
.myGallery {
display: table-cell;
height: 220px;
text-align: center !important;
vertical-align: middle !important;
width: 110px;
}
.myGallery img {
text-align: center;
vertical-align: middle;
width: auto !important;
}
function ChangeHW(hdnValue)
{
if (hdnValue==1)
{
//i want to remove height and width attribute of image
//this is working..
$('div.myGallery > img').removeAttr('width');
$('div.myGallery > img').removeAttr('height');
}
else
{
//i want to set height and width attribute of image
//this is not working..i cant set width-height using this line od code
$('div.myGallery > img').css('width', '110px');
$('div.myGallery > img').css('height', '220px');
}
}
Toutes les idées?
.attr() ne fonctionne pas .. – ravidev