JQUERY的这一行是什么意思?
我想在我的网页中添加 jQuery OpenID 插件。
实际上我想将它添加到 MasterPage 的内容页面中,
$(function () { $("form.openid:eq(0)").openid(); });
但是出现了严重错误,并且 Javascript 代码永远不会执行。
我想这与我的页面呈现如下这一事实有关
<form id="form1" runat="server">
...
</form>
,这里有一个名为 Javascript 的部分
//jQuery OpenID Plugin 1.1
//Copyright 2009 Jarrett Vance http://jvance.com/pages/jQueryOpenIdPlugin.xhtml
$.fn.openid = function() {
var $this = $(this);
var $usr = $this.find('input[name=openid_username]');
和如下的 Jquery
$(function () { $("form.openid:eq(0)").openid(); });
那么上面的行是什么意思?
I would like to add the jQuery OpenID Plug-in in my webpage.
Actually i would like to add it into a content page of a MasterPage
$(function () { $("form.openid:eq(0)").openid(); });
But something goes terribly wrong, and the Javascript code is never executed.
I guess this has to do with the fact that my page renders as follows
<form id="form1" runat="server">
...
</form>
and here comes a part of Javascript called
//jQuery OpenID Plugin 1.1
//Copyright 2009 Jarrett Vance http://jvance.com/pages/jQueryOpenIdPlugin.xhtml
$.fn.openid = function() {
var $this = $(this);
var $usr = $this.find('input[name=openid_username]');
and the Jquery as follows
$(function () { $("form.openid:eq(0)").openid(); });
So what does the line above mean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
可以细分为这样...
简单地说,就是在页面加载后调用内部函数。
意味着在具有 cssclass openid 的表单的第一个实例上调用方法
openid()
。Can be broken down to this...
Simply means call the inner function once the page is loaded.
Means call the method
openid()
on the first instance of a form with the cssclass openid.这意味着获取第一个表单元素具有“openid”类,然后运行 openid() 函数
It means get the first form element has class "openid" then run openid() function
它使用名为“openid”的 css 类调用第一个 (eq(0)) 表单标签上的 openid() 方法
由于您在表单标签上错过了 class="openid",因此它不会被执行
It invokes the method openid() on the first (eq(0)) form-tag with a css class named "openid"
It doesn't get executed since you miss class="openid" on your form-tag
请尝试这样做:
您的代码将查找第一个
class
属性设置为“openid”的form
元素。Try this instead:
Your code will look for the first
form
element whoseclass
attribute is set to "openid".