I am having an issue with the code that I was given as an example from a previous SO question - it is working about 95% but the order array is appearing empty why?
HTML:
<input class="order" value="<?php echo $order; ?>" type="text" />
JS:
$('body').on("click", "#brands_by_category_submit_btn", function (e) {
e.preventDefault();
var self = $(this);
var order = [];
var id = $("#manID").data("id");
var brand_name = $("#brand_name").data("id");
var data = grabData(true);
$(".order").each(function(){
order.push($(this).text());
})
if(data.length)
{
var data_array = {
id : id,
brand_name : brand_name,
cat_id : data,
order : order,
state : 1
};
.text()
returns the text content of a node, like <p>this text here</p>
. An <input />
element doesn't have text content, so $('input').text()
will just return an empty string. Your order
array should be an array of empty strings then. Maybe you want to extract the values?
$(".order").each(function(){
order.push($(this).val());
});
怎么样:
order.push($(this).val());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.