0
我試圖獲取綁定到模態的data-id的值。 這裏是代碼bootstrap data-id在javascript中未定義
<i class="fa fa-envelope" aria-hidden="true" data-target="#btnSendSMS" data-toggle="modal" data-id="ISBN564541"></i>
//彈出模型
<div id="btnSendSMS" style="display: none" class="modal fade TransParentAll" role="dialog">
<div class="modal-dialog" id="C_Model_Dialog">
<div class="modal-content" id="C_Model_Content">
<div class="modal-header" id="C_Model_Header">
<h4 class="modal-title">Send SMS</h4>
</div>
<div class="modal-body" id="C_modal_body">
<form class="AddFreelancerForm">
<div class="form-group">
<span class="pull-left">SMS</span>
<input type="text" id="textSMS" class="form-control" placeholder="write something here" />
</div>
</form>
</div>
<div class="modal-footer" id="C_Model_Footer">
<button id="btnsave" type="button" class="btn c_G_Btn pop_upSaveBtn" value="1" onclick="SendSMS()">
<i class="fa fa-floppy-o" aria-hidden="true"></i>
Send
</button>
<button id="btnCancel" type="button" class="btn c_R_Btn" data-dismiss="modal" value="1" onclick="CloseWindow()">
<i class="fa fa-times" aria-hidden="true"></i>
Close
</button>
</div>
</div>
</div>
</div>
// JS
function SendSMS() {
var candidateId = $(this).data('id');
var can=$(this).attr("data-id") ;
但我在按鈕上單擊這兩個值越來越不確定。
您是否包含['jquery'](https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js)庫鏈接? – prasanth
是的。我已經包含了 –
這個''在'SendSMS'中引用了什麼? – Satpal