为什么这段javascript不能进行相应的功能呢?
<html><head>
<script language="JavaScript" type="text/javascript">
var str = "please";
var content = document.form1.content.value;
function getFocus() {if(content==str) {content = ''}}
function lostFocus() {if( content=''){content = str}}
</script></head>
<body>
<form id="form1">
<input name="content" onblur="lostFocus();" onfocus="getFocus()" type="text" value="please" size="25">
</form>
</body>
</html>

解决方案 »

  1.   

    function lostFocus() {if( content=''){content = str}}
    改成
    function lostFocus() {if( content==''){content = str}}
      

  2.   


    <html><head>
    <script language="JavaScript" type="text/javascript">
    var str = "please";
    function getFocus(input) {if(input.value) {input.value = ''}}
    function lostFocus(input) {if(!input.value){input.value = str}}
    </script></head>
    <body>
    <form id="form1">
    <input name="content" onblur="lostFocus(this);" onfocus="getFocus(this)" type="text" value="please" size="25">
    </form>
    </body>
    </html>
      

  3.   

    //写错了。<html><head>
    <script language="JavaScript" type="text/javascript">
    var str = "please";
    function getFocus(input) {if(input.value == str) {input.value = ''}}
    function lostFocus(input) {if(input.value == ""){input.value = str}}
    </script></head>
    <body>
    <form id="form1">
    <input name="content" onblur="lostFocus(this);" onfocus="getFocus(this)" type="text" value="please" size="25">
    </form>
    </body>
    </html>
      

  4.   

    输入框的特效: 没获取焦点时显示:please  
               
                点击后please消失,开始你的输入
    请看这个页面顶部  搜索按钮 旁边的 输入框   就是这个效果
      

  5.   

    谁能看懂
    http://topic.csdn.net/u/20100624/10/a1e13308-e6ab-4e5a-a89e-4ed918e8a78a.html?seed=849730198&r=66469015#r_66469015
    lihui_shine的代码?什么逻辑?
      

  6.   

    你也不用到处贴呀^_^
    我这就来解释回复此帖<html><head>
    <script language="JavaScript" type="text/javascript">
    var str = "please";
    function getFocus(obj){if(obj.value==str) {obj.value = ''}}
    function lostFocus(obj){if(obj.value==''){obj.value = str}}
    </script></head>
    <body>
    <form id="form1">
    <input name="content" onblur="lostFocus(this);" onfocus="getFocus(this)" type="text" value="please" size="25">
    </form>
    </body>
    </html>