-1
 function brands(id)
 {

   var brand_id = $("#brands").val(id); //id is also getting here
   alert(brand_id);    // but not show in the alert box
 }

why to show the the localhost say [object][object] there are no any result getting to me.

Shafizadeh
  • 9,960
  • 12
  • 52
  • 89
NisarAd
  • 1
  • 2

1 Answers1

0
$("#brands").val(id)

You are assigning value and not reading value from it, also.val(<with param>) returns jQuery's object for the given DOM element, hence when you use alert() you get [object object]. Use brand_id.val(), you will get the expected results.

$(function() {
  var v1 = $('#t1').val('hi');
  alert(v1); /* jquery object */
  alert(v1.val()); /* actual value */
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="t1" />