开发者

jQuery Validate Element

开发者 https://www.devze.com 2022-12-31 20:03 出处:网络
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\" :

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

精彩评论

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