English 中文(简体)
查阅日志[]并产生错误
原标题:Accessing Jquery object [] and get error

I m new in Jquery, I can t access the elements within the Jquery object.

var iconNumber=$( #tblFeedControlBar ).find( td ).length;    // 8 
var iconNumber=$( #tblFeedControlBar ).find( td )[0].width(); // error
$( #tblFeedControlBar ).find( td ).get(0).after(iconArrow);  // error
最佳回答

当你成为 j子时,请上<>em>。 DOM是该职位的一个分支,而不是一个 j子。 <代码>植被/代码”的功能也是如此。 (事实上,除非您使用负面指数,get/code>。) 确实,你只读到<条码>[];其负数则做的工作微不足道。

如果你想要第一个要素的width(我假定 with 意为width),那么如果你在一组内容上说的话,你会知道:

var iconNumber=$( #tblFeedControlBar ).find( td ).width();

虽然这套措施可能不止一个要素,但一般而言,“目标”行动在规定的 首先要素上运作。 (APIC是非对称的;“定型”业务按整组计算。)

如果您想到second的宽度。 内容:

var iconNumber=$($( #tblFeedControlBar ).find( td )[1]).width();

或使步骤更加明确:

var rawSecondElement = $( #tblFeedControlBar ).find( td )[1];
var wrapperForIt = $(rawSecondElement);
var getItsWidth: wrapperForIt.width();
问题回答

A reference to a DOM element shouldn t have a with() method, which should cause a...

<代码>un specified is not a function.

......ror.

var iconNumber=$( #tblFeedControlBar ).find( td )[0].with(); 

没有with(> 方法,可指width()。

$( #tblFeedControlBar ).find( td ).get(0).after(iconArrow); 

.get(0)之后,请您获得法定的 no(而不是j Query Object),以便您不能再将另一条 j( after()方法连接起来。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签