하나의 진행률 표시줄
js 코드
(function($) {
//Main Method
$.fn.reportprogress = function(val,_handler, maxVal) {
var handler = _handler;
var max = 100;
if (maxVal)
max = maxVal;
return this.each(function() {
var div = $(this);
var innerdiv = div.find(".progress");
/* div div, div */
if (innerdiv.length != 1) {
innerdiv = $("<div class='progress'></div>");
div.append("<div class='text'> </div>");
$("<span id='progress-text' class='text'> </span>").css("width",
div.width()).appendTo(innerdiv);
div.append(innerdiv);
}
/* div */
var width = Math.round(val / max * 100);
innerdiv.css("width", width/100*160 + "px");
div.find(".text").html(width + " %");
div.unbind("click");
div.click(fun);
div.unbind("mouseover");
div.mouseover(function (){div.css("cursor","text");});
div.unbind("mouseout");
div.mouseout(function (){div.css("cursor","default");});
function fun(event){
// alert("left:"+ div[0].offsetLeft+"width:"+div[0].offsetWidth);
// alert("click left:" + event.clientX);
var width = Math.round((event.clientX - div.offset().left)/(div[0].offsetWidth-2)*100);
if(width > 100){
return;
}
innerdiv.css("width", width + "%");
div.find(".text").html(width + " %");
handler(width);
//alert('here');
}
});
};
})(jQuery);
css 코드
#progressbar {
BORDER-RIGHT: black 1px solid;
BORDER-TOP: black 1px solid;
BORDER-LEFT: black 1px solid;
WIDTH: 160px;
COLOR: black;
BORDER-BOTTOM: black 1px solid;
POSITION: relative;
HEIGHT: 20px
}
#progressbar DIV.progress {
OVERFLOW: hidden;
WIDTH: 0px;
POSITION: absolute;
HEIGHT: 20px;
BACKGROUND-COLOR: blue;
}
#progressbar DIV.progress .text {
COLOR: white;
POSITION: absolute;
TEXT-ALIGN: center;
FONT-SIZE: larger;
}
#progressbar DIV.text {
WIDTH: 100%;
POSITION: absolute;
HEIGHT: 100%;
TEXT-ALIGN: center;
FONT-SIZE: larger;
}
사용법
$("#progressbar").reportprogress(hasReplay, function(width) {
// Util.debug("width = "+width);
object.setCurrent(Math.round(width * total / 100));
}, total);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다른 사람의 웹사이트 편집: contenteditable 및 designMode그래도 우리가 그렇게 할 수 있다고 생각하는 것은 멋진 일입니다. 제가 강조하고 싶었던 일종의 관련 API가 실제로 몇 개 있기 때문에 오늘 그것을 가져왔습니다. contenteditable는 "true" 값이 할당...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.