gpt4 book ai didi

jquery - 将值从 Jquery 变量传递到 window.open

转载 作者:行者123 更新时间:2023-12-01 04:13:52 25 4
gpt4 key购买 nike

我有以下 Jquery 代码,用于警告此变量中 HTML 字段的值 $(".attachmentsUpload input.file").val());

我的问题是我想像这样将此值传递给变量 val

window.open("http://abc.com/crop/test.php?val="+$(".attachmentsUpload input.file").val()),"_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400");

但它没有传递该值。

<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>

<script type='text/javascript'>//<![CDATA[
$(function(){
$(".attachmentsUpload input.file").live("change", function () {
if ($(".attachmentsUpload input.file").val() == "") {
return;
}
// your ajax submit
alert("submit value of the file input field=" + $(".attachmentsUpload input.file").val());


$(".attachmentsUpload input.file").replaceWith('<input type="file" class="file" name="file" />');
});
});//]]>

window.open("http://abc.com/crop/test.php?val="+$(".attachmentsUpload input.file").val()),"_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400");

</script>
</head>
<body>
<form class="attachmentsUpload" action="/UploadHandler.ashx" method="post" enctype="multipart/form-data">
<input type="file" class="file" name="file" />

</form>
</body>
</html>

最佳答案

据我了解:

$(".attachmentsUpload input.file").replaceWith('<input type="file" class="file" name="file" />');

那么:

$(".attachmentsUpload input.file").val() 返回空字符串

关于jquery - 将值从 Jquery 变量传递到 window.open,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16859208/

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