注意className应用的是那个样式
<script type="text/javascript">
function add(){
var p1 = document.getElementById("p1");
p1.className = "one";
}
function modify(){
var p2 = document.getElementById("p2");
p2.className = "two";
}
</script>
<script type="text/javascript">
function add(){
var p1 = document.getElementById("p1");
p1.className = "one";
}
function modify(){
var p2 = document.getElementById("p2");
p2.className = "two";
}
</script>
2018-04-16
<script type="text/javascript">
function hidetext()
{
var mychar = document.getElementById("con").style.display="none";
}
function showtext()
{
var mychar = document.getElementById("con").style.display="block";
}
</script>
function hidetext()
{
var mychar = document.getElementById("con").style.display="none";
}
function showtext()
{
var mychar = document.getElementById("con").style.display="block";
}
</script>
2018-04-16
<script type="text/javascript">
function rec(){
document.write("welcome"+"<br>");
var mymessage=confirm("are you a girl") ;
if(mymessage==true)
{
document.write("hey girl!");
}
else
{
document.write("hey boy!");
}
}
function rec(){
document.write("welcome"+"<br>");
var mymessage=confirm("are you a girl") ;
if(mymessage==true)
{
document.write("hey girl!");
}
else
{
document.write("hey boy!");
}
}
2018-04-16
<p id="con">你好</p>
<script type="text/javascript">
var mychar
mychar=document.getElementById(“id”);
document.write(mychar); //输出获取的P标签。
</script>
<script type="text/javascript">
var mychar
mychar=document.getElementById(“id”);
document.write(mychar); //输出获取的P标签。
</script>
2018-04-16
function openWindow(){
var message=confirm("是否打开新窗口")
if(message==true){
var add=prompt("输入网址:","http://www.imooc.com")
}
else{
return 0;
} window.open(add,'_blank','height:500px,width=:400px,left=0,height=100px,menubar=no,toolbar=no,status=yes')
}
var message=confirm("是否打开新窗口")
if(message==true){
var add=prompt("输入网址:","http://www.imooc.com")
}
else{
return 0;
} window.open(add,'_blank','height:500px,width=:400px,left=0,height=100px,menubar=no,toolbar=no,status=yes')
}
<script>
var mywin=window.open('http://www.imooc.com','_blank','width=600px, height=400px, top=100px, left=0px');
function close(){
mywin=window.close();
}
</script>
</head>
<body>
<input type="button" name="buttom" value="点击我关闭窗口!" Onclick="close()"/>
</body>
var mywin=window.open('http://www.imooc.com','_blank','width=600px, height=400px, top=100px, left=0px');
function close(){
mywin=window.close();
}
</script>
</head>
<body>
<input type="button" name="buttom" value="点击我关闭窗口!" Onclick="close()"/>
</body>
2018-04-15
id是不可以重复的,class却可以重复,之前我一直以为id的功能不如class,现在明白了。
我把id比作成一个人,class是衣服。换了class就是给id穿上不同的衣服,但是人无论如何也变不了
我把id比作成一个人,class是衣服。换了class就是给id穿上不同的衣服,但是人无论如何也变不了
2018-04-15
mychar.style.color="#F00";
mychar.style.backgroundColor="#CCC";
mychar.style.width="300px" //注意引号和大小写,之前就忘记写引号了
mychar.style.backgroundColor="#CCC";
mychar.style.width="300px" //注意引号和大小写,之前就忘记写引号了
2018-04-15
function openWindow(){
var newBox=confirm("是否打开");
if(newBox==true){
prompt(" https://www.imooc.com/code/1642","请输入网址");
window.open(" https://www.imooc.com/code/1642","_blank","width=400px,height=500px,menubar=no,toolbar=no");
}else{
alert("nothing")
}
}
var newBox=confirm("是否打开");
if(newBox==true){
prompt(" https://www.imooc.com/code/1642","请输入网址");
window.open(" https://www.imooc.com/code/1642","_blank","width=400px,height=500px,menubar=no,toolbar=no");
}else{
alert("nothing")
}
}