Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用arctext jquery插件使用范围标记创建动态文本弧_Javascript_Jquery_Html - Fatal编程技术网

Javascript 使用arctext jquery插件使用范围标记创建动态文本弧

Javascript 使用arctext jquery插件使用范围标记创建动态文本弧,javascript,jquery,html,Javascript,Jquery,Html,我喜欢动态创建arctext,所以我使用arctext jquery插件,并使用range html标记选择文本中的圆弧或曲线 这是我的html代码 <label>Curve:</label> <input type="range" name="value" id="value" min="-100" max="100" value="0" /> <p id="textvalue"> I wanna to be curve</p>

我喜欢动态创建arctext,所以我使用arctext jquery插件,并使用range html标记选择文本中的圆弧或曲线

这是我的html代码

<label>Curve:</label>
<input type="range" name="value" id="value" min="-100" max="100" value="0" />
<p  id="textvalue"> I wanna to be curve</p> 
曲线:

我想成为曲线

javascript代码:

<script type="text/javascript">
$(function(){
  $("#value").change(function () {
    var newValue = $('#value').val();
    changetext(newValue);
  });
  function changetext(newValue){
    console.log(newValue);
    var pos;
    if(newValue>0)
      pos=1;
    else{
      pos=-1;
      $("#textvalue").hide();
      $("#textvalue").show().arctext({radius:newValue, dir: pos});
    }
  }
});
</script>

$(函数(){
$(“#值”)。更改(函数(){
var newValue=$('#value').val();
changetext(newValue);
});
函数changetext(newValue){
console.log(newValue);
var-pos;
如果(新值>0)
pos=1;
否则{
pos=-1;
$(“#textvalue”).hide();
$(“#textvalue”).show().arctext({radius:newValue,dir:pos});
}
}
});

但这段代码只适用于第一次拖动。但后来它保持不变。范围值是不断变化的,这是我通过console.log知道的。

我想您的意思是将$(“textvalue”).hide()内容放在if语句的大括号之外。此外,滑块变为负值,文本只接受正值。我看了一下这个,我能让它工作的唯一方法就是完全移除元素,用不同半径的

$(function(){
$("#value").change(function () {
 var newValue = $('#value').val();
 changetext(newValue);
});
function changetext(newValue){
  console.log(newValue);
  var pos;
  if(newValue>0)
   pos=1;
  else{
   pos=-1;
  }
  var text = $("#textvalue").text();
  $("#textvalue").remove();
  $('body').append('<p id="textvalue">'+ text +'</p>');
  $("#textvalue").arctext({radius:Math.abs(newValue), dir: pos});
 }
});
$(函数(){
$(“#值”)。更改(函数(){
var newValue=$('#value').val();
changetext(newValue);
});
函数changetext(newValue){
console.log(newValue);
var-pos;
如果(新值>0)
pos=1;
否则{
pos=-1;
}
var text=$(“#textvalue”).text();
$(“#textvalue”).remove();
$('body')。追加('

'+text+'

'); $(“#textvalue”).arctext({radius:Math.abs(newValue),dir:pos}); } });