Jquery取消按钮输入占位符文本

时间:2013-01-17 23:51:44

标签: javascript jquery

我之前问了这个问题,但没有正确的信息就问道,这里再说一遍。我需要做的是取消按钮“list_btn_cancel”关闭弹出活动并替换输入占位符所估算的内容。 此表是输入。

    <table  width="100%" style="line-height:0px" >
        <tr>
            <td><p>1.</p></td>
            <td><input name="activities_thoughts_1" id="activities_thoughts_1" type="text" style="width:345px;" placeholder="Type or click list button &gt;" /></td>
            <td><input type="button" id="thoughts_1"  class="list_btn ext_thoughts" value="List &gt;" /></td>
        </tr>

        </table>


    **this table is the popup**

    <div id="popup_activity" class="box_list">

          <div id="list_question_btn"></div></div>
        </div>
        <div id="activity_area_content" style="padding-bottom:5px;" >
    <form name="form1">   

    <table class="style2" width="100%">
        <tr><br />
          <td width="8%" align="right"><input name="thoughts_list" id="thoughts_list_0" class="thoughts_list" type="radio" value="It is just terrible that my child will not be a normal kid" /></td>

      </table>
    </form>
    </div>
  </div>

    <div><table><td><a style="margin-left:290px" onclick="closeDialog('popup_activity');"><input type="button" id="thoughts_cancel"  class="list_btn list_btn_cancel" value="Cancel &gt;" placeholder="Type or click list button &gt;"  /></a></td>&nbsp;<td><a onclick="closeDialog('popup_activity');"><input style="margin-left:10px" type="button" id="close_thoughts"  class="list_btn list_btn_close" value="Close &gt;" /></a></td></table></div></div>

    **Here is the script**
    $('.list_btn').button();

    $('#popup_activity').css("display","none");
    $('#list_help').css("display","none");

    $('.ext_thoughts').click(function(){
        openDialog('popup_activity');
        btn_id= $(this).attr('id');
    });

    $('.thoughts_list').click(function(){
        ( $(this).attr('id'));
        $("#activities_" +btn_id).val($(this).val());
    });

2 个答案:

答案 0 :(得分:0)

很难弄清楚你要从你的问题中做什么,但如果你想要的只是文本输入恢复到它的占位符文本,只需将其值设置为空白。

$("#activities_thoughts_1").val(''); 

以下是http://jsfiddle.net/arG5f/

的示例

答案 1 :(得分:0)

好的,不太明白你想要什么,但这就是我想你想要的:

<!DOCTYPE html>
<html lang="en">
  <head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function()
    { 
    $('.ext_thoughts').click(function(){
        $("#popup_activity").toggle();  
    });
    $('.list_btn_cancel').click(function(){
            $("#popup_activity").hide();
        $("#activities_thoughts_1").val('');
     }); 
    });
</script>
  </head>
  <body>
<input name="activities_thoughts_1" id="activities_thoughts_1" type="text" style="width:345px;" placeholder="Type or click list button " />
<br>
<input type="button" id="thoughts_1"  class="list_btn ext_thoughts" value="Show/Hide List" />
<input type="button" id="thoughts_cancel"  class="list_btn list_btn_cancel" value="Cancel" />
<br>


<div id="popup_activity" class="box_list" style="display:none;">
This is the pop up division         
</div>
</body>
</html>

FIDDLE HERE