Click here to Skip to main content
15,886,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to show small image of width 250px by using jquery i tried to set the width of the image, in jquery i have use this command. here is my jqury code, even after giving this command image comes with its original size, i.e.600px etc etc...

my html td tag shows this value, but not affect the image. so any one tell how to set the size of image so that what ever its original weight and height but its shows the with of 250px.

Jquery
<script language="javascript" type="text/javascript"      src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"> </script> <script  language="javascript" type="text/javascript">
$(document).ready(function() {

 $("table td #n1WPQ4").css("width","250px")

 });
</script>


HTML
<table class="ms-formtable" border="0" cellpadding="0" cellspacing="0" width="100%">
 <tbody>
 <tr>
<td nowrap="" valign="top" width="190px" class="ms-formlabel">
<nobr>Picture</nobr>
</td>

<td valign="top" class="ms-formbody" width="400px" id="n1WPQ4" style="width: 250px;">

 <img src="http://img.dashtees.com/mini-gloves/pakistan/pakistan.03.jpg" alt=""> 
</td>
</tr>
<tr>
<td nowrap="" valign="top" width="190px" class="ms-formlabel">
<nobr>Name</nobr>
</td>
<td valign="top" class="ms-formbody" width="400px" id="n2WPQ4">
<a onfocus="OnLink(this)" href="http://sharepoint/_layouts/15/listform.aspx?  PageType=4&ListId={06ABE63D-FD6E-4EC6-A473-  CF648BE5B384}&ID=2&ContentTypeID=0x0100C0EFC789E8F94545923F62567A0C1A52"   önclick="EditLink2(this,7);return false;" target="_self">glove</a> </td></tr><tr><td nowrap=""  valign="top" width="190px" class="ms-formlabel"><nobr>Description</nobr></td><td valign="top"  class="ms-formbody" width="400px" id="n3WPQ4"><div dir="" class="ms-rtestate-field"></div> </td>  </tr><tr><td nowrap="" valign="top" width="190px" class="ms-formlabel"><nobr>Article</nobr></td><td valign="top" class="ms-formbody" width="400px" id="n4WPQ4"> </td></tr></tbody></table>
Posted
Updated 21-Feb-14 3:15am
v2

Hi,

You have given width twice, so try to give once and try it.

HTML
<table><tbody><tr><td valign="top" class="ms-formbody">width="400px" id="n1WPQ4" style="width: 250px;"></td></tr></tbody></table>

or you could try this
HTML
<table><tbody><tr><td valign="top" class="ms-formbody" width="400px" id="n1WPQ4" style="width: 250px !important;"></td></tr></tbody></table>

Hope this helps you a bit

Regards,
RK
 
Share this answer
 
You should have placed the id="n1WPQ4" in the image tag not the td tag:
XML
<td valign="top" class="ms-formbody" width="400px"  style="width: 250px;">
    <img src="http://img.dashtees.com/mini-gloves/pakistan/pakistan.03.jpg" alt=""  id="n1WPQ4">
</td>

then, the jquery:
$("#n1WPQ4").css("width","250px")
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900