JSFiddle代碼無法在我自己的頁面中工作我有一些代碼在JSFiddle中工作但我無法在我自己的頁面中運行。HTML<body style="background-color: #000000">
<form oninput="amount.value=range.value" style="color:#1ec2c5;">
<output name="amount" for="range">2</output><a> KM</a>
<input type="range" name="range" min="1" max="9" step="1" value="2" id="test"></body>CSSinput[type="range"]{
-webkit-appearance: none;
-moz-apperance: none;
border-radius: 6px;
width: 225px;
height: 6px;
border: 2px solid #eceef1;
outline:none;
background-image: -webkit-gradient(
linear,
left top,
right top,
color-stop(0.15, #eceef1),
color-stop(0.15, #0c0d17)
); }input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none !important;
background-color: #1ec2c5;
border: 3px solid #000000;
height: 25px;
width: 25px;
border-radius: 20px;}JavaScript的$('input[type="range"]').change(function () {var val = ($(this).val() - $(this).attr('min')) / ($(this).attr('max') - $(this).attr('min'));$(this).css('background-image',
'-webkit-gradient(linear, left top, right top, '
+ 'color-stop(' + val + ', #eceef1), '
+ 'color-stop(' + val + ', #0c0d17)'
+ ')'
); });如果我接受代碼并放入HTML / JS(鏈接在頭部)/ CSS(鏈接在頭部)文件中,CSS可以工作,但JavaScript不能。我已經(jīng)嘗試用$(this)元素的id 替換但仍然沒有運氣。
JSFiddle代碼無法在我自己的頁面中工作
慕田峪4524236
2019-07-31 10:30:30