我有以下鏈接:獲取數據目標動態
<a href="edit/2" class="popup" data-toggle="modal" data-target="#productVariantModal"> <span class="glyphicon glyphicon-edit"></span></a>
我想獲得的數據目標動態,所以我可以重用我javescript代碼。
我已經試過這樣的事情:
var target = $(this).closest('[data-target]');
但這開不工作。
任何建議,歡迎。
謝謝。
你需要的ID嗎? – underscore
@samitha no。我想要數據目標的價值。 – sanders
@sanders .attr('data-target')不能動態工作? –