Phi*_*enn 1 jquery jquery-plugins
我一直认为jQuery中应该有一个.id而不是.attr('id').
问:你如何编写插件,以便myObject.id返回myObject.attr('id')?
为了争论,你可以这样做.
// extend jQuery object with your id
$.fn.id = function() {
// return the id of the first DOM element.
return this[0].id;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
488 次 |
| 最近记录: |