function rec(){
var age = prompt("你多少岁?");
if(age<20){
document.write("哟,小鲜肉");
}else if(age>20&&age<30){
document.wirte("你好,刚过青春期的骚年");
}else if(age>30&&age<40){
document.wirte("大叔,好猥琐");
}else if(age>40){
document.write("伯伯,回家看粤剧去吧(微笑脸)");
}
}
var age = prompt("你多少岁?");
if(age<20){
document.write("哟,小鲜肉");
}else if(age>20&&age<30){
document.wirte("你好,刚过青春期的骚年");
}else if(age>30&&age<40){
document.wirte("大叔,好猥琐");
}else if(age>40){
document.write("伯伯,回家看粤剧去吧(微笑脸)");
}
}
2016-08-09
已采纳回答 / 慕慕mu
因为如果你直接写var mychar= document.getElementById("con")的话,那就是获取P这个元素,你可以这样写 var mychar=document.getElementById("con").innerHTML,这样就可以获取P里面的文本内容了
2016-08-09
function openWindow(){
// 新窗口打开时弹出确认框,是否打开
if(confirm("打开吗")){
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
var url=prompt("请输入网址","http://www.imooc.com")
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
window.open(url,"_blank","toolbar=no, menubar=no, width=400, height=500")
}
}
// 新窗口打开时弹出确认框,是否打开
if(confirm("打开吗")){
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
var url=prompt("请输入网址","http://www.imooc.com")
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
window.open(url,"_blank","toolbar=no, menubar=no, width=400, height=500")
}
}
function openWindow(){
var q =confirm("是否打开");
if(q==true)
{
var w=prompt("打开输入1")
if(w==1)
{
window.open(' http://www.imooc.com/','_blank','width=400,height=500,menubar=no,toolbar=no');
}
else(null)
}
else(null)
}
var q =confirm("是否打开");
if(q==true)
{
var w=prompt("打开输入1")
if(w==1)
{
window.open(' http://www.imooc.com/','_blank','width=400,height=500,menubar=no,toolbar=no');
}
else(null)
}
else(null)
}
2016-08-09
//定义"取消设置"的函数
function reSet() {
var isReset = confirm("确定取消设置?");
if (isReset) {
text.style.cssText = "null";
}
}
function reSet() {
var isReset = confirm("确定取消设置?");
if (isReset) {
text.style.cssText = "null";
}
}
//通过id获取节点
var text = document.getElementById("txt");
//定义"改变颜色"的函数
function changeColor() {
text.style.color = "#CCC";
text.style.backgroundColor = "blue";
}
var text = document.getElementById("txt");
//定义"改变颜色"的函数
function changeColor() {
text.style.color = "#CCC";
text.style.backgroundColor = "blue";
}
已采纳回答 / virgil_wilson
document.write("原标题:"+mychar.innerHTML+"")这一句的内容 电脑先输出显示之后 再执行innerHTML改变h2标签中的原来是javascript的内容
2016-08-09
为什么用了innerHTML只是改变了h2标签中的原来是javascript的内容,document.write("原标题:"+mychar.innerHTML+"<br>")这一句的内容却没改变呢?
2016-08-09