How do i use substr on 2 divs?
How can i do so numb's last 2 numbers randoms like "text's" last 2?
I can't do it with, document.write(str.substr(-2));
beacause its two divs..
How do i do?
<div id="numb">72-450 04 <script type="text/javascript">
document.write(Math.floor(Math.random()*9开发者_运维技巧0) +10);
</script></div>
<div id="text">
49</div>
If I understand correctly you want to print the same random number as las two chars of "#numb" div and text div. For that you can try this:
<script type="text/javascript">
var lastNumber = Math.floor(Math.random()*90) +10;
</script>
<div id="numb">72-450 04 <script type="text/javascript"> document.write(lastNumber); </script></div>
<div id="text"> <script type="text/javascript"> document.write(lastNumber); </script></div>
精彩评论