views:

19

answers:

2
   $(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 $("#buttons").val(''); $("#buttons").html('');

It didnt work

A: 
$('#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().

jAndy
A: 
<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?

bradenkeith
You do not need the "javascript:" inside an onclick on an anchor (<a>) tag. This is messy, and considered bad practice. http://stackoverflow.com/questions/372159/do-you-ever-need-to-specify-javascript-in-an-onclick http://crisp.tweakblogs.net/blog/the-useless-javascript-pseudo-protocol.html http://stackoverflow.com/questions/2479557/why-is-it-bad-practice-to-use-links-with-the-javascript-protocol
Slobaum
I never use that. It was just a quick example of how it's working using his previous practice in the append(). I would use $().bind('click', ...)
bradenkeith