Reputation: 3848
I am trying to get the fileid
and filename L98BIv2_inv_12.txt
when a user clicks on plupload_delete
class
<<span id="fileId-1">
<a style="clear:left" class="item ui-corner-all" href="#" title="">
<span id="fileId-1" class="ui-icon ui-icon-close plupload_delete"></span>
<span class="value plupload_file_name">L98BIv2_inv_11.txt</span>
</a>
<a class="item ui-corner-all" href="#">
<span class="value noicon plupload_file_size">1 KB</span>
</a>
<a class="item progress ui-corner-all" href="#" style="display:none">
<span class="value noicon plupload_file_status">Uploading ...</span>
</a>
<span id="fileId-2">
<a style="clear:left" class="item ui-corner-all" href="#" title="">
<span id="fileId-2" class="ui-icon ui-icon-close plupload_delete"></span>
<span class="value plupload_file_name">L98BIv2_inv_12.txt</span>
</a>
<a class="item ui-corner-all" href="#">
<span class="value noicon plupload_file_size">2 KB</span>
</a>
<a class="item progress ui-corner-all" href="#" style="display:none">
<span class="value noicon plupload_file_status">Uploading ...</span>
</a>
Below is my jQuery function
$('.plupload_delete', target).click(function(e) {
var fid = $(this).attr("id")
fid = fid.replace("fileId-","");
});
I am able to get the fileId
but I couldnt get the filename L98BIv2_inv_12.txt
from span
class value plupload_file_name
can someone help me with this?
Upvotes: 1
Views: 170
Reputation: 8291
All you need is $(this).text()
:
$('.plupload_delete', target).click(function(e) {
var fid = $(this).attr("id")
fid = fid.replace("fileId-","");
var name = $(this).next().text();
});
Please note that you need .next()
because the span
containing the file name is just after the clicked span
.
Upvotes: 3