javascript - Refresh element using only JS console - Stack Overflow

I am needing to refresh only one element using the JS console, rather than refreshing the whole page. I

I am needing to refresh only one element using the JS console, rather than refreshing the whole page. I've got code that already works, but it depends on refreshing the page.

  if (document.readyState === "plete") { vote(); }


function vote() { 
//Do some stuff

setTimeout(function(){ 
location.reload(); 
}, 500);
}

I am needing to refresh only one element using the JS console, rather than refreshing the whole page. I've got code that already works, but it depends on refreshing the page.

  if (document.readyState === "plete") { vote(); }


function vote() { 
//Do some stuff

setTimeout(function(){ 
location.reload(); 
}, 500);
}
Share Improve this question asked Sep 24, 2016 at 16:10 Jared BledsoeJared Bledsoe 5595 silver badges15 bronze badges 3
  • What do you mean with refreshing one elem?? – Jonas Wilms Commented Sep 24, 2016 at 16:15
  • I would like to reload only one specific element, say I had a div id with #element. Instead of refreshing the page, I would like to only refresh that specified element. – Jared Bledsoe Commented Sep 24, 2016 at 16:31
  • I think you dont understand the sense of HTML – Jonas Wilms Commented Sep 24, 2016 at 16:46
Add a ment  | 

3 Answers 3

Reset to default 2

function reload(){
  var container = document.getElementById("testDiv");
  var newContent = "After reload";
  container.innerHTML= newContent;
}
<button><a href="javascript: reload()">Reload</a></button>
<br/>
<div id="testDiv">
Before reload.
</div>

Looks like you just want to reload an iframe:

your normal html
<iframe src="page that should be reloaded.html">old browser</iframe>
<script>
function reload(){ document.getElementsByTagName("iframe")[0].reload();
 }
 </script>

What does refreshing one element mean? If you have a div with an id of element then you can just change the contents of that div using javascript and it will make the changes in your html. If the div contains "HI" then you can use document.getElementById("element").innerHTML and change it to whatever you want. Or you can change its attributes, you can add elements inside that div using javascript as well, what is it you are trying to do exactly? I assume that no matter what it is, you can just grab that element via its id and change it whenever you want it to refresh.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745360152a4624321.html

相关推荐

  • javascript - Refresh element using only JS console - Stack Overflow

    I am needing to refresh only one element using the JS console, rather than refreshing the whole page. I

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信