简体   繁体   English

我需要将某些 jquery upload_progress 参数转换为 javascript

[英]I need to convert certain jquery upload_progress params to javascript

The following code is working in jquery for ajax file upload以下代码适用于 jquery 用于 ajax 文件上传

//upload_percent = Math.ceil(upload_position / upload_total * 100);
$('.upload_progress').css('width', upload_percent + '%');
$('.upload_progress').text(upload_percent + '%');

html html

<div class="upload_progress" style="width:0%">0%</div>

Now I need to convert the above jquery code to javascript in other to display upload_progress of a file.现在我需要将上面的 jquery 代码转换为 javascript 以显示文件的upload_progress。

I know in javascript, one can do something like the code document.getElementById('upload_progres') but my issue is that upload_progress is also showed in html div as class.我知道在 javascript 中,可以执行类似代码document.getElementById('upload_progres') ,但我的问题是,upload_progress 在 html div 中也显示为 ZA2F2ED4F8EBC2CBB4C21A29DC40。

document.getElementsByClassName('upload_progress')[0] - would select the first element with this class. document.getElementsByClassName('upload_progress')[0] - 将 select 与此 class 的第一个元素。 Then instead of .width() you should use element.style.width(upload_percent + '%')然后你应该使用element.style.width(upload_percent + '%')而不是.width() )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM