首页 > 代码库 > JS数值变量和字符串变量
JS数值变量和字符串变量
代码:
<script type="text/javascript"> window.alert("你好"); document.write("你好"); document.write("<hr>"); var a = "10";//所谓链接就是将左右字符串连接起来 var b = 10; var c = a+b; document.write(c); document.write("<hr>"); var name = "贾光圣"; var xuehao = "1201010739"; var sex = "男"; var adress = "成都"; var str = ‘‘ str += ‘<table width="500" border="1" align="center">‘; str += ‘ <tr>‘; str += ‘ <th colspan="6" align="center">西南石油大学学生信息表</th>‘; str += ‘ </tr>‘; str += ‘ <tr>‘; str += ‘ <td>姓名:</td>‘; str += ‘ <td>学号:</td>‘; str += ‘ <td>性别:</td>‘; str += ‘ <td>生源地:</td>‘; str += ‘ </tr>‘; str += ‘ <tr>‘; str += ‘ <td>‘+name+‘</td>‘; str += ‘ <td>‘+xuehao+‘</td>‘; str += ‘ <td>‘+sex+‘</td>‘; str += ‘ <td>‘+adress+‘</td>‘; str += ‘ </tr>‘; str += ‘</table>‘; document.write(str); </script>
运行结果:
<script type="text/javascript">
window.alert("你好");
document.write("你好");
document.write("<hr>");
var a = "10";//所谓链接就是将左右字符串连接起来
var b = 10;
var c = a+b;
document.write(c);
document.write("<hr>");
var name = "贾光圣";
var xuehao = "1201010739";
var sex = "男";
var adress = "成都";
var str = ‘‘
str += ‘<table width="500" border="1" align="center">‘;
str += ‘ <tr>‘;
str += ‘ <th colspan="6" align="center">西南石油大学学生信息表</th>‘;
str += ‘ </tr>‘;
str += ‘ <tr>‘;
str += ‘ <td>姓名:</td>‘;
str += ‘ <td>学号:</td>‘;
str += ‘ <td>性别:</td>‘;
str += ‘ <td>生源地:</td>‘;
str += ‘ </tr>‘;
str += ‘ <tr>‘;
str += ‘ <td>‘+name+‘</td>‘;
str += ‘ <td>‘+xuehao+‘</td>‘;
str += ‘ <td>‘+sex+‘</td>‘;
str += ‘ <td>‘+adress+‘</td>‘;
str += ‘ </tr>‘;
str += ‘</table>‘;
document.write(str);
</script>
<script type="text/javascript">
window.alert("你好");
document.write("你好");
document.write("<hr>");
var a = "10";//所谓链接就是将左右字符串连接起来
var b = 10;
var c = a+b;
document.write(c);
document.write("<hr>");
var name = "贾光圣";
var xuehao = "1201010739";
var sex = "男";
var adress = "成都";
var str = ‘‘
str += ‘<table width="500" border="1" align="center">‘;
str += ‘ <tr>‘;
str += ‘ <th colspan="6" align="center">西南石油大学学生信息表</th>‘;
str += ‘ </tr>‘;
str += ‘ <tr>‘;
str += ‘ <td>姓名:</td>‘;
str += ‘ <td>学号:</td>‘;
str += ‘ <td>性别:</td>‘;
str += ‘ <td>生源地:</td>‘;
str += ‘ </tr>‘;
str += ‘ <tr>‘;
str += ‘ <td>‘+name+‘</td>‘;
str += ‘ <td>‘+xuehao+‘</td>‘;
str += ‘ <td>‘+sex+‘</td>‘;
str += ‘ <td>‘+adress+‘</td>‘;
str += ‘ </tr>‘;
str += ‘</table>‘;
document.write(str);
</script>
JS数值变量和字符串变量
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。