gpt4 book ai didi

IE 中的 JQuery 和表单属性发生变化

转载 作者:行者123 更新时间:2023-12-01 06:31:49 25 4
gpt4 key购买 nike

我想使用 JQuery 更改表单属性。在其他浏览器中它工作正常,但在 IE(6,7,8) 中不行。

代码:

action = '/controller/action/id/';
target = 'upload_iframe';
enctype = 'multipart/form-data';

$('#form1').attr("action",action);
$('#form1').attr("target",target);
$('#form1').attr("enctype",enctype);

那么问题出在哪里呢?我们将不胜感激您的帮助。

最佳答案

试试这个

$('#form1').attr("action","/controller/action/id/");
$('#form1').attr("target","upload_iframe");
$('#form1').attr("enctype","multipart/form-data");

我刚刚尝试过这个,它适用于我的每个浏览器..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function() {
$("#btn").click(function() {
$('#form1').attr("action","/controller/action/id/");
$('#form1').attr("target","upload_iframe");
$('#form1').attr("enctype","multipart/form-data");

});
});
</script>

</head>

<body>

<form id="form1" action="something.html" method="post" name="forma" target="target" enctype="nope">

<a href="#" id="btn">Uno mas</a>

</form>

</body>
</html>

它也适用于我,刚刚测试了 IE7 和 8:

    action = '/controller/action/id/';
target = 'upload_iframe';
enctype = 'multipart/form-data';

$('#form1').attr("action",action);
$('#form1').attr("target",target);
$('#form1').attr("enctype",enctype);

console.log($('#form1').attr("action") + " " + $('#form1').attr("target") + " " + $('#form1').attr("enctype"));

alert($('#form1').attr("action") + " " + $('#form1').attr("target") + " " + $('#form1').attr("enctype"));

关于IE 中的 JQuery 和表单属性发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2514253/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com