May I ask about how can I remove the value of q
, when the class .close
is clicked?
Here with my source code:
JavaScript
x
18
18
1
$(document).on('click', '.close', function () {
2
$(this).parents('p').remove();
3
4
})
5
6
$('#Q1DocPath').change(function () {
7
8
var path = $(this).val();
9
10
if (path != '' && path != null) {
11
var q = path.substring(path.lastIndexOf('\') + 1);
12
13
$('#lblQ1Doc').html('<br/>' + '<p>' + q + '<a class="close"><font color="red">x</font><a>' + '</p>');
14
15
}
16
})
17
18
Advertisement
Answer
If I understand the question correctly you need to remove the value of q
only from HTML.
The easiest way is to wrap the value with the span
tag.
JavaScript
1
17
17
1
$(document).on('click', '.close', function () {
2
$(this).prev('span').remove();
3
4
})
5
6
$('#Q1DocPath').change(function () {
7
8
var path = $(this).val();
9
10
if (path != '' && path != null) {
11
var q = path.substring(path.lastIndexOf('\') + 1);
12
13
$('#lblQ1Doc').html('<br/>' + '<p><span>' + q + '</span><a class="close"><font color="red">x</font><a>' + '</p>');
14
15
}
16
})
17
Let me know if you needed something else or injected HTML can’t be modified, I’ll correct the answer.