html text与button,HTML BUTTON WITH TEXT AND IMAGE

You could use the 'style' property of to achieve what you are looking for. Within the style property you could set display:none, to hide the . To make it visible again, just change display back to display:inline when a button gets clicked. Try the following:

Project2

Favorite Animals

Slow Loris

Sloth

οnmοuseοver="this.style.backgroundColor='red';"

οnmοuseοut="this.style.backgroundColor='white';"

οnclick="

document.getElementById('sloth').style='width:200px;height:150px;display:none;'

document.getElementById('slow').style='width:200px;height:150px;display:inline;'

document.getElementById('outputDiv').innerHTML=

'This animal might look like a harmless, big-eyed baby ewok, but ' +

'the slow loris is one of the only venomous mammals in the world. ' +

'Its subtle nature makes it popular in the illegal pet trade, but this ' +

'furry creature also carries a toxin that is released from the brachial ' +

'gland on the sides of its elbows. If threatened, the loris can take ' +

'the toxin into its mouth and mix it with saliva. The animal may also ' +

'lick or rub its hair with this mixture to deter predators from attack. ' +

'The toxin can cause death by anaphylactic shock in some people.';">

οnmοuseοver="this.style.backgroundColor='red';"

οnmοuseοut="this.style.backgroundColor='white';"

οnclick="

document.getElementById('slow').style='width:200px;height:150px;display:none';

document.getElementById('sloth').style='width:200px;height:150px;display:inline;'

document.getElementById('outputDiv').innerHTML=

'Sloths—the sluggish tree-dwellers of Central and South America—spend ' +

'their lives in the tropical rain forests. They move through the canopy ' +

'at a rate of about 40 yards per day, munching on leaves, twigs and buds. ' +

'Sloths have an exceptionally low metabolic rate and spend 15 to 20 hours ' +

'per day sleeping. And surprisingly enough, the long-armed animals are ' +

'excellent swimmers. They occasionally drop from their treetop perches ' +

'into water for a paddle.'">

Edit

If you don't mind changing your code a bit, a cleaner solution would be:

Project2

Favorite Animals

Slow Loris

This animal might look like a harmless, big-eyed baby ewok, but

the slow loris is one of the only venomous mammals in the world.

Its subtle nature makes it popular in the illegal pet trade, but this

furry creature also carries a toxin that is released from the brachial

gland on the sides of its elbows. If threatened, the loris can take

the toxin into its mouth and mix it with saliva. The animal may also

lick or rub its hair with this mixture to deter predators from attack.

The toxin can cause death by anaphylactic shock in some people.

Sloth

Sloths—the sluggish tree-dwellers of Central and South America—spend

their lives in the tropical rain forests. They move through the canopy

at a rate of about 40 yards per day, munching on leaves, twigs and buds.

sloths have an exceptionally low metabolic rate and spend 15 to 20 hours

per day sleeping. And surprisingly enough, the long-armed animals are

excellent swimmers. They occasionally drop from their treetop perches

into water for a paddle.

οnmοuseοver="this.style.backgroundColor='red';"

οnmοuseοut="this.style.backgroundColor='white';"

οnclick="

document.getElementById('slow').style='text-align:center;display:inline';

document.getElementById('sloth').style='text-align:center;display:none'">

οnmοuseοver="this.style.backgroundColor='red';"

οnmοuseοut="this.style.backgroundColor='white';"

οnclick="

document.getElementById('sloth').style='text-align:center;display:inline';

document.getElementById('slow').style='text-align:center;display:none'">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值