天天看点

js innerHTML outerHTML innerText

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> new document </title>

<meta http-equiv="content-type" content="text/html;charset=utf-8">

<meta name="generator" content="editplus" />

<meta name="author" content="" />

<meta name="keywords" content="" />

<meta name="description" content="" />

<mce:style type="text/css"><!--

.div1{border:1px solid #efef00; margin:0 0 10px 10px;width:388px;height:88px;position:absolute;top:0;left:0;}

.div1 input{position:relative;top:36px;}

.div2{border:1px solid #ef00ef; margin-left:10px;width:388px;height:88px;position:absolute;top:100px;left:0;}

.div2 input{position:relative;top:36px;}

#reverseme{margin-left:96px;}

.but1{background:#ff00ff;font-weight:bold;}

#div3{border:1px solid #00ef00;margin-left:10px;width:388px;height:88px;position:absolute;top:200px;left:0;};

--></mce:style><style type="text/css" mce_bogus="1"> .div1{border:1px solid #efef00; margin:0 0 10px 10px;width:388px;height:88px;position:absolute;top:0;left:0;}

.div1 input{position:relative;top:36px;}

.div2{border:1px solid #ef00ef; margin-left:10px;width:388px;height:88px;position:absolute;top:100px;left:0;}

.div2 input{position:relative;top:36px;}

#reverseme{margin-left:96px;}

.but1{background:#ff00ff;font-weight:bold;}

#div3{border:1px solid #00ef00;margin-left:10px;width:388px;height:88px;position:absolute;top:200px;left:0;};</style>

</head>

<body>

<div class="div1">

<input type="radio" name="muticheckbox" class="" οnclick="fuc_click(this)" style="margin-left:96px;" mce_style="margin-left:96px;"/>

<input type="radio" name="muticheckbox" class="" οnclick="fuc_click(this)"/>

<input type="radio" name="muticheckbox" class="" οnclick="fuc_click(this)"/>

<input type="radio" name="muticheckbox" class="" οnclick="fuc_click(this)"/>

<input type="radio" name="muticheckbox" class="" οnclick="fuc_click(this)"/>

<input type="radio" name="muticheckbox" class="" οnclick="fuc_click(this)"/>

</div>

<div class="div2">

<input type="text" name="" maxlength="18" size="18" class="" id="reverseme"/>

<input type="button" name="" class="but1" οnclick="str_reserve(document.getElementById('reverseme').value)" value="翻转"/>

</div>

<div id="div3">

<b>what am I?</b>

<input type="button" name="" class="but1" οnclick="distinct_dom(this)" value="outerHTML"/>

<input type="button" name="" class="but1" οnclick="distinct_dom(this)" value="innerHTML"/>

<input type="button" name="" class="but1" οnclick="distinct_dom(this)" value="innerText"/>

</div>

</body>

<mce:script language="JavaScript" type="text/javascript" src="http://www.pingan.com/app_js/jquery-1.3.2.js" mce_src="http://www.pingan.com/app_js/jquery-1.3.2.js"></mce:script>

<mce:script language="JavaScript" type="text/javascript"><!--

function fuc_click(a){

var doct=document.getElementsByName("muticheckbox");

for(var i=0;i<doct.length;i++){i

if(a===doct[i]){

//var i_= i+1;

alert("你选择的是第: "+ (i+1) +" 个;")

break;

//return i+1;

}

}

return i+1;

}

function str_reserve(str){

if(str==""||str==null){

alert("请先输入字符串,然后按按钮!");

return false;

}

var afterstr = str.split("").reverse().join("");

document.getElementById('reverseme').value = afterstr;

return afterstr;

}

function distinct_dom(str){

var ss_ = "";

var ss = document.getElementById("div3");

try{

if(str.value=="outerHTML"){

ss_ = ss.outerHTML;

}else if(str.value=="innerHTML"){

ss_ = ss.innerHTML;

}else if(str.value=="innerText"){

ss_ = ss.innerText;

}

}catch(e){}

if(ss_)alert(ss_);

return ss_;

}

// --></mce:script>

</html>

下一篇: js弹窗

继续阅读