eclipse中js代码如何设置可折叠?

JavaScript052

eclipse中js代码如何设置可折叠?,第1张

js代码设置可折叠设置:

设置代码折叠在菜单栏的窗口-->首选项

1、选择常规-->编辑器-->structure text editors,可以看到Enable folding选项,打上勾就可以使用代码折叠功能,但还要在具体的语言中设置。

2、选择js-->编辑器-->折叠,选择启用折叠就可以让js的代码折叠了。

用document的onmousedown 响应鼠标在页面上的点击事件 IE中用event.srcElement; FF中用e.target; 能获得鼠标点击的对象 然后你判断该对象是否为选择城市的这个div 不是的话就隐藏该 div 我想怎么用jquery你应该知道 吧 $(document).mousedown( function(event){ alert(event.target.id)//这样会弹出你单击的元素的id,你可以在这里写你的程序了 } ))

一、首先定义一个JavaScript function,如下:

function puckerMenu(level) {

var levelLength = ('row' + level).length

var toDo = '0'

for (var iCount = 0 iCount <document.all.lengthiCount++){

if ( document.all[iCount].id.indexOf('row' + level) >-1 &&( document.all[iCount].id.length >levelLength)) {

if ( document.all('level' + level).src.indexOf('minus.gif') >-1 ) {

document.all[iCount].style.display = 'none'

toDo = '1'

} else {

document.all[iCount].style.display = 'block'

toDo = '0'

}

}

}

if ( toDo == '1' ) {

document.all('level' + level).src = 'images/plus.gif'

} else {

document.all('level' + level).src = 'images/minus.gif'

}

}

二、然后在网页上定义一个div和一个ul,注意div中要包含一个id为level开头的image和一个onclick事件,ul中id要包含row,默认情况下是展开的,如果需要默认为闭合,则要在ul中加入style="display:none"

例子如下:

<body>

<divstyle="CURSOR: hand"

onclick="puckerMenu('1')"><IMGid=level1

src="images/minus.gif">public class DataAccess</div>

<ulid=row1>

<li>private string connString

<divstyle="CURSOR: hand"

onclick="puckerMenu('2')"><IMGid=level2

src="images /plus.gif">protected DbConnection OpenConnection()</div>

<ulid=row2style="display:none">{...}</ul>

<li>

Other

</ul>

</body>