我有以下代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$("#widget_list").hide();
$("#click_me").click(function() {
$(this).parents( "#clipboard" ).find( "#widget_list" ).toggle();
});
});
</script>
</head>
<body>
<div id="clipboard">
<div href="#" id="click_me" style="border:solid 1px black;text-align:center;cursor:pointer;">
\/
</div>
<div id="widget_list" style="border:solid 1px black;text-align:center;">
some stuff here
</div>
</div>
some other stuff here
</body>
</html>
而不是将文本硬编码some stuff here
为#widget_list
. 如何将该文本添加到#widget_list
,当它的切换状态可见时,以及如何从#widget_list
它的切换状态隐藏时删除该文本?