javascript - How do I assign different data-target to different option values so different models shows up? -


i tried both switch cases , if else statements models id accept, reject, review show none working me. want confirm if doing wrong in terms of logic , syntax.

<select class="input-sm form-control" id="pendingbulk">    <option value="0">bulk actions</option>    <option value="1">accept</option>    <option value="2">reject</option>    <option value="3">report</option> </select> <button class="btn btn-sm btn-default" id="pendingapply" data-toggle="modal">apply</button> <script>    $("#pendingapply").click(function() {    var action = $('#pendingbulk').val();    switch(parseint(action)) {    case 1:      $(this).data("target") === "#accept";      break;    case 2:      $(this).data("target") === "#reject";      break;    case 3:      $(this).data("target") === "#report";      break;    default:    }); </script> 

or

<script>    $("#pendingapply").click(function() {    var action = $('#pendingbulk').val();    if (action = 1) {      $(this).data("target") === "#accept";    } else if (action = 2) {      $(this).data("target") === "#reject";    } else if (action = 3) {      $(this).data("target") === "#report";    };    }); </script> 

try this:

$("#pendingapply").on('click', function() {  var action = $('#pendingbulk').val();  var $t=$(this);  switch(parseint(action)) {  case 1:    $t.attr("data-target","#accept" );    break;  case 2:    $t.attr("data-target","#reject" );    break;  case 3:    $t.attr("data-target","#report" );    break;  default:  } }); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -