You used $('selector').val('')
, and this is for input fields, and will not work here!
I suggest you use one of the following methods:
$(document).ready(function(){
$("#delete-1").click(function(){
$('#display1').html('');
});
$("#delete-2").click(function(){
document.getElementById('display2').innerHTML ="";
});
$("#delete-3").click(function(){
$('#display3').empty();
});
$("#delete-4").click(function(){
$('#display4').text('');
});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<pre id="display1">
Here is pre content
</pre>
<br/>
<pre id="display2">
Here is pre content
</pre>
<br/>
<pre id="display3">
Here is pre content
</pre>
<br/>
<pre id="display4">
Here is pre content
</pre>
<br/>
<a id="delete-1" href="#">Delete #1</a>
<a id="delete-2" href="#">Delete #2</a>
<a id="delete-3" href="#">Delete #3</a>
<a id="delete-4" href="#">Delete #4</a>
Run codeHide result source
share