Answers for "jquery id for body"

2

jquery get element by id

<script>
$(document).ready(function(){
    $("#myBtn").click(function(){
        var elmId = $("#test").attr("id");
        alert(elmId);
    });
});
</script>

<body>
    <div id="testDiv">Data of the Div</div>
    <br>
    <button type="button" id="myBtn">Show Div ID</button>
</body>
Posted by: Guest on April-14-2020
0

jquery not calling id from div called in ajax

$(document).on('change', '#typeship', function(e){
  var courier = $('#courier').val();
  var cityfrom = $('#cityfrom').val();
  var cityto = $('#cityto').val();
  var weight = $('#tot_weight').val();
  var shiptype = $(this).val();
  alert (shiptype); // didn't response -> no alert pop up 
  $.ajax({
    type: "POST",
    url: "<?php echo base_url();?>backend/Ctransaction/showShipCost",
    data: {Courier:courier, Cityfrom:cityfrom, Cityto:cityto, Weight:weight, Shiptype:shiptype},
    datatype:"html",
    success: function(data){
      $('#detailcost').html(data);
    }
  });
});
Posted by: Guest on September-25-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language