English 中文(简体)
jquery 语法 - 为什么需要一个带有文本框的数组索引?
原标题:jquery syntax - why the need for an array index with a textbox?

有人能告诉我为什么在下面的代码的第5行使用数组索引吗? #agree 指的是一个复选框, # terms 是指一个文本框。 目的是确定用户是否在单击复选框之前滚动到文本框底部。 谢谢 。

$(document).ready(function() {
  $( #agree ).attr( disabled ,  disabled );

  $( #terms ).scroll(function() {
    var textarea_height = $(this)[0].scrollHeight;
    var scroll_height = textarea_height - $(this).innerHeight();

    var scroll_top = $(this).scrollTop();

    if (scroll_top == scroll_height){
      $( #agree ).removeAttr( disabled );
    }
  });
});
最佳回答

s 因为 crollH8 是DOM元素属性。

所以 $( this) 是一个jQuery 对象, $(this) [0] 是一个DOM- 元素(您也可以使用 .get(0) 而不是 [0] )

this.scrollH8 - 这应与 $(this)[0].scrollH8 相同

问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

pdo database abstraction

Can someone help me to see what is going wrong with this setup I build the @sql query in the function below like this. The extra quotes are setup in the conditions array. $sql .= " WHERE $...

I wish I could correlate an "inline view"

I have a Patient table: PatientId Admitted --------- --------------- 1 d/m/yy hh:mm:ss 2 d/m/yy hh:mm:ss 3 d/m/yy hh:mm:ss I have a PatientMeasurement table (0 to ...

Syntax help! Php and MYSQL

Original: $sql = "SELECT DATE(TimeAdded) AS Date, $column_name FROM Codes ORDER BY TimeAdded ASC"; Altered: $sql = "SELECT DATE("m", TimeAdded ) AS Date, ColumnName FROM TableName ORDER BY ...

Is this code Equivalent

I am not a fan of the following construction if (self = [super init]) { //do something with self assuming it has been created } Is the following equivalent? self = [super init]; if (self != ...

热门标签