javascript:如何在span中触发单击事件,有点难,高手请进

javascript:如何在span中触发单击事件,有点难,高手请进,第1张

首先你查看一下js错误,movediv()未定义,然后查看一下源文件就明白是怎么回事了,document.write将重新生成HTML源码,以前的代码已经丢失,所以我给你改写了一下;

还有"this.movediv()"的"this"是错误的,去掉;

修改后的代码如下,希望对你有用:

<html>

<head>

<script>

function display()

{

var ss="<table name='tabframe'align='center' style='text-align:centerbackground-color:green'>"

ss+="<tr><td><input type=button style='color:redwidth:200height:100border:1px solid #111111' value='div留言' onclick=document.getElementById('divframe').style.display='block'></td></tr></table>"

ss+="<div id='divframe' style='width:500pxheight:100pxdisplay:noneposition:absolutebackground-color:#ddddddtop:200left:200'>"

ss+="<table align='center' border=1 style='text-align:centerborder:1px solid #aaaaaa '>"

ss+="<tr><td style='text-align:center'><span onclick=movediv()>我的显示信息</span></td></tr>"

ss+="<tr><td>文字</td></tr>"

ss+="<tr><td><span style='cursor:hand' onclick=document.getElementById('divframe').style.display='none'>[关闭]</td></tr>"

ss+="</table>"

ss+="</div>"

window.document.body.innerHTML+=ss

/*

document.write("<table name='tabframe'align='center' style='text-align:centerbackground-color:green'>")

document.write("<tr><td><input type=button style='color:redwidth:200height:100border:1px solid #111111' value='div留言' onclick=document.getElementById('divframe').style.display='block'></td></tr></table>")

document.write("<div id='divframe' style='width:500pxheight:100pxdisplay:noneposition:absolutebackground-color:#ddddddtop:200left:200'>")

document.write("<table align='center' border=1 style='text-align:centerborder:1px solid #aaaaaa '>")

document.write("<tr><td style='text-align:center'><span onclick=this.movediv()>我的显示信息</span></td></tr>")

document.write("<tr><td>文字</td></tr>")

document.write("<tr><td><span style='cursor:hand' onclick=document.getElementById('divframe').style.display='none'>[关闭]</td></tr>")

document.write("</table>")

document.write("</div>")

*/

}

function movediv()

{

alert('aa')

}

</script>

</head>

<body onload="display()">

</body>

</html>

流浪:

1. (v) be a nomaddrift about

2. (v) wanderroam

3. be homeless

4. (adj) unsettled (e.g., population)vagrant

其它相关解释:

<gipsy><vagrancy><vagabondism><run the streets><rove><vagabondize><vagabondage><nomadize><nomadism><on the wallaby track><vagrantness><vagrantly><divagation><divagate><gypsy><mooch>

例句与用法:

1. 他过着流浪生活。

He leads a vagabond life.

2. 那个流浪汉不得不乞求钱财。

The vagrant had to beg for money.

3. 人而无一住址者是为流浪汉,住址有二者是为放荡儿。

A man without an address is a vagabonda man with two address is a libertine.

4. 杰克在他父母死后成了流浪儿。

Jack run the street after the death of his parents.

5. 他是个衣衫褴褛的流浪者。

He is a tramp in shabby old clothes.

1.beggar n.:

a person, typically a homeless one, who lives by asking for money or food

(尤指无家可归的)乞丐,叫花子

2.tramp n.

a person who travels from place to place on foot in search of work or as a vagrant or beggar

漂泊者,流浪汉,乞丐

根据意义,tramp意义比beggar广些,

除了乞丐,还可表漂泊者,流浪汉。

希望满意,祝您进步:)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7351831.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存