当前位置: 首页 > 图文教程 > 网络编程 > Javascript > jQuery的一些注意

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 jQuery的一些注意


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 253 ::
收藏到网摘: n/a

用jQuery的时候,刚开始一直以为用$("#someid")取出来的是dom对象的扩展,于是就很自在的用$("#someid").value,$("#someid").text之类的,可惜一直取不出要的值。后来才发现,它并不是扩展。如果要取类似上面的值,就要用$("#someid").val(),$("#someid").text()。这些还是在查看了它的api文档以后才发现的,不禁要感慨一声,JavaScripty的api文档多重要啊。
  这两个方法:$("#formId").submit(), $("#formId").submit(function(){ ...}),两者不一样的是,前者是调用submit方法,后者是增加onsubmit方法。
  用jQuery调用ajax,是非常方便的,$.get, $.post,看了这两个方法,就会发现了。javascript用fp是挺方便的,如果是Java的话,目前也就只会用匿名类的方法,代码还不简洁,而且一点fp的味道都没有。
  用thickbox(从http://jquery.com/plugins进去,找到thickbox的主页,看一下example就会用了),要写弹出窗口的时候要注意了,如果是用#td_inline的话,比如这样写

<div id="messageDiv">
<input type="text" id="nameTextfield"/>
</div>

然后按钮这样写:
<a href="#td_inline?width......&inlineid=messageDiv" class="thickbox"/>
现在的问题就是,如果你在弹出的窗口中,要取得nameTextfield的value(或其他属性),就取不出你想要的值了,因为实际上弹出的窗口是另一个新的div,里面的对象跟messageDiv里面的对象是不一样的,这时候如果想用document.getElementById("nameTextfield")就要小心了,因为取到的文本框并不是弹出窗口中的。