html 调用手机短信,innerHTML应用模拟手机短信发送

本文展示了如何使用HTML+CSS样式创建一个具有交互功能的网页元素,包括图片切换和内容添加。通过JavaScript和jQuery代码,实现了点击按钮将输入框内容添加到页面并显示,同时图片在点击时可以进行状态切换。这是一个基本的前端交互实例,适合初学者理解网页动态效果的实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、效果图。

2b2faed285401a621f175e70d711f189.png

二、HTML+CSS样式。

.box{ width:500px; margin:90px auto;}

.wrad_box{ width:320px; height:400px; border:1px solid #000; padding:20px; margin-bottom:20px;  overflow:auto; }

.img{ width:30px; height:30px;cursor:pointer;}

.btn1,.text{ height:30px; line-height:30px;}

.text{ width:150px; border:1px solid #ccc;}

.btn1{ background:#ff6600; color:#fff; padding:0 10px; line-height:0; cursor:pointer;}

.active{ overflow:hidden; margin-bottom:8px;}

.active1{ overflow:hidden; margin-bottom:8px;}

.active div{ width:270px; float:left;}

.active a{ background:#21c618; color:#fff; float:right; padding:5px;line-height:24px;}

.active1 div{float:right; width:270px;}

.active1 a{ float:left;padding:5px; background:#ded6e7; line-height:24px; color:#181018;}

.active1 img{ float:left;}

    表情

三、javaScript代码。

window.onload = function(){

var oDiv =document.getElementById('wrad_box');

var oImg =document.getElementById('img');

var oText =document.getElementById('text');

var oBtn =document.getElementById('btn1');

var off =true;

var le ='active';

oImg.onclick =function(){

if(off){

oImg.src ='img/2.gif';

le='active1';

off=false;

}else{

oImg.src ='img/1.gif';

le='active';

off=true;

}

};

oBtn.onclick =function(){

if(oText.value==''){

alert('请输入内容');

}else{

            //oDiv.innerHTML+=oText.value+'表情'+'
';

            oDiv.innerHTML='

'+oText.value+'
'+' 表情
'+oDiv.innerHTML;

oText.value='';

}

};

};

四、jquery代码。

$(function(){

var off =true;

$('#img').click(function(){

if(off){

$('#img').attr('src','img/2.gif');

off=false;

}else{

$('#img').attr('src','img/1.gif');

off=true;

}

});

$('#btn1').click(function(){

        $('#wrad_box').html($('#text').val()+'表情'+'
'+$('#wrad_box').html());

$('#text').val('');

});

})

注意jquery是js的一个库,所以在使用jquery需要引入jq的库文件。库文件在附件中下载。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值