开发者

jQuery Validate Element

jQuery Validate plugin passes element value to inline开发者_开发技巧 validate functions. I'm trying to get element's id and an error telling that "element.attr is not a function" :

function someFunction(element) {
  var elementId = element.attr('id');
}

rules: {
  someFiled: {
    required: someFunction
  }
}


You get passed the DOM node, not a jQuery wrapped version, so do this:

function someFunction(element) {
  var elementId = $(element).attr('id');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜