简单的脚本不起作用 [英] Simple script does not work

查看:65
本文介绍了简单的脚本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以看到为什么这个简单的脚本不会使元素可见?它是
以隐藏的方式开始,但在单击按钮时不会显示。这之前

为我工作过,但我看不出有什么不同。


谢谢



< script language =" Javascript">

<! -

function addnewsub(){

var newsubject = document .getElementById(''newsub'');

newsubject.style.display ='''';

}

// - >

< / script>


< input name =" Submit2"类型= QUOT按钮"类= QUOT; BODYTEXT" onClick =" addnewsub()"

value =" New">


这里是来自表格的相关代码


< tr id =" newsub"风格= QUOT;显示:无;"类= QUOT; DynamicForms">

将TD>&安培; NBSP;< / TD>

将TD>类型受试对象; / TD> <无线电通信/>
将TD>&安培; NBSP;< / TD>

将TD列跨度= QUOT; 2英寸;><输入名称= QUOT;文本框" type =" text"

class =" BodyText">

< input name =" addnewsub"类型= [提交" class =" BodyText"

value =" Add">< / td>

< / tr>

Can anyone see why this simple script doesnt make the element visible? It
starts of as hidden but will not show when the button is clicked. This has
worked for me before but I cannot see what is different.

Thanks


<script language="Javascript">
<!--
function addnewsub(){
var newsubject = document.getElementById(''newsub'');
newsubject.style.display='''';
}
//-->
</script>

<input name="Submit2" type="button" class="BodyText" onClick="addnewsub()"
value="New">

here is the relevent code from table

<tr id="newsub" style="display:none;" class="DynamicForms">
<td>&nbsp;</td>
<td>Type Subject </td>
<td>&nbsp;</td>
<td colspan="2"><input name="textfield" type="text"
class="BodyText">
<input name="addnewsub" type="submit" class="BodyText"
value="Add"></td>
</tr>

推荐答案

mantrid写道:
mantrid wrote:

任何人都可以看到为什么这个简单的脚本不会使元素可见?
Can anyone see why this simple script doesnt make the element visible?



你错过了表格标签......习惯使用有效的,

漂亮,漂亮甚至性感的HTML将使你的脚本冒险

比平时更愉快 - 试一试;)

You''re missing the table tag... Getting the habit of working with valid,
nice, beautiful and even sexy HTML will make your scripting adventure
far more enjoyable than usual - give it a try ;)




mantrid写道:

mantrid wrote:

任何人都可以看到为什么这个简单的脚本不会使元素可见?
Can anyone see why this simple script doesnt make the element visible?


newsubject.style.display ='''';
newsubject.style.display='''';



尝试将display属性设置为显式值,例如block

或inline。


有一个显示的属性列表,这里
http://www.w3schools.com/css/pr_class_display.asp


IIRC刚刚取消了元素的属性,就像你做的那样,将导致

属性从范围链中的较高位继承。

Try setting the display property to an explicit value, such as "block"
or "inline."

There is a list of properties for display, here
http://www.w3schools.com/css/pr_class_display.asp

IIRC just unsetting an element''s property, as you have done, will cause
the property to be inherited from higher up in the scope chain.




Elegie < el **** @ invalid.comwrote in message

news:45 *********************** @ news。 free.fr ...

"Elegie" <el****@invalid.comwrote in message
news:45***********************@news.free.fr...

mantrid写道:
mantrid wrote:

任何人都可以看到为什么这个简单的脚本不会元素可见吗?
Can anyone see why this simple script doesnt make the element visible?



你错过了表格标签......养成使用有效的习惯,

美观,漂亮甚至性感的HTML将使你的脚本冒险

比平时更愉快 - 试一试;)


You''re missing the table tag... Getting the habit of working with valid,
nice, beautiful and even sexy HTML will make your scripting adventure
far more enjoyable than usual - give it a try ;)



i刚离开那桌子很大。只是想展示相关的

片段

i just left that out as the table is large. just wanted to show the relevant
snippet


这篇关于简单的脚本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆