开发者

remove appended html

开发者 https://www.devze.com 2023-01-13 08:59 出处:网络
$(function() { if(map_flag == 0) $(\"#buttons\").append(\'&nbsp;&nbsp;<input type=\"button\" value=\"Import\" class=\"ui-state-default ui-corner-all\" onclick=\"javascript:import_q();\" /&g
   $(function() {
           if(map_flag == 0)
              $("#buttons").append('&nbsp;&nbsp;<input type="button" value="Import" class="ui-state-default ui-corner-all" onclick="javascript:import_q();" />');

       });

function upload_1()
{
  $("#buttons").val('');
   $("#buttons").html('')
}

In upload_1 function how to remove the html that is appended in $("#buttons") i tried $("#but开发者_开发问答tons").val(''); $("#buttons").html('');

It didnt work


<script type="text/javascript">
   $(function() {
              $("#buttons").append('&nbsp;&nbsp;<input type="button" value="Import" class="ui-state-default ui-corner-all" onclick="javascript:import_q();" />');

       });

function upload_1()
{
   $("#buttons").html('')
}
</script>
<div id="buttons"></div>
<a href="#"  onclick="javascript:upload_1();" >Clear</a>

Works fine for me... How are you initializing the upload_1 function?


$('#buttons').html('');

will replace the innerHTML from the #buttons element.

$('#buttons').replaceWith('');

will replace the element #buttons itself and substitue it with '' (nothing)

Sidenote: There is a typo in your code, a missing ; behind .html().

0

精彩评论

暂无评论...
验证码 换一张
取 消