修改input的text 通过jquery的html获取值 未变化
2023-09-11 14:21:23 时间
修改input的text 通过jquery的html获取值 未变化
扩展一个方法 ,通过formhtml()来取代html()
(function ($) {
var oldHTML = $.fn.html;
$.fn.formhtml = function () {
if (arguments.length) return oldHTML.apply(this, arguments);
$("input,textarea,button", this).each(function () {
this.setAttribute('value', this.value);
});
$(":radio,:checkbox", this).each(function () {
// im not really even sure you need to do this for "checked"
// but what the heck, better safe than sorry
if (this.checked) this.setAttribute('checked', 'checked');
else this.removeAttribute('checked');
});
$("option", this).each(function () {
// also not sure, but, better safe...
if (this.selected) this.setAttribute('selected', 'selected');
else this.removeAttribute('selected');
});
return oldHTML.apply(this);
};
//optional to override real .html() if you want
// $.fn.html = $.fn.formhtml;
})(jQuery);
相关文章
- jQuery Ajax calls and the Html.AntiForgeryToken()
- JQuery
- jQuery源码-dom操作之jQuery.fn.html
- VSCode调试Html中的脚本 vscode前端常用插件推荐,搭建JQuery、Vue等开发环境 vsCode 添加浏览器调试和js调试的方法总结 VS Code - Debugger for Chrome调试js
- jquery $.proxy使用 Jquery实现ready()的源码
- jquery中 $ 和 jQuery 及 $() 的区别
- jQuery Video Extend
- 【Jquery】jQuery获取URL參数的两种方法
- 使用jQuery的 load() 方法加载html公共模块
- vue框架(三)_vue引入jquery、bootstrap
- jQuery的attr方法处理checkbox的问题
- jQuery技术内幕:深入解析jQuery架构设计与实现原理1
- jquery 在ul中取得第一级的li
- 《jQuery Cookbook中文版》——1.1 在HTML页面中包含jQuery程序库代码
- 《jQuery Cookbook中文版》——1.15 获取和设置HTML内容
- 《jQuery、jQuery UI及jQuery Mobile技巧与示例》——9.2 技巧:用单个HTML文件服务多张页面
- Jquery_jquery中attr和prop的区别
- Jquery_JQuery之DataTables强大的表格解决方案
- jQuery基础 - 改变CSS样式
- jquery常用见的正则表达式
- Web 之 html 如何显示隐藏Html元素的两种方法简单整理
- jQuery HTML-删除元素