JQuery选择td标记内的元素 [英] JQuery select an element inside a td tag

查看:111
本文介绍了JQuery选择td标记内的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过使用jquery显示宽度为250px的小图像我试图设置图像的宽度,在jquery我已经使用此命令。这是我的jqury代码,即使在给出这个命令后,图像也带有原始大小,即600px等等......



我的html td标签显示了这个值,但是不影响图像。所以任何人都告诉如何设置图像的大小,以便它的原始重量和高度,但它显示250px的。



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.

<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>







<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>

推荐答案

(document).ready(function(){
(document).ready(function() {


table td #n1WPQ4)。css( width 250px

});
< / script >
("table td #n1WPQ4").css("width","250px") }); </script>







<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>






您已经给了两倍宽度,所以尝试一次尝试。



Hi,

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

<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

<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


Hope this helps you a bit

Regards,
RK


这篇关于JQuery选择td标记内的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆