我想使用jquery将先前从数据库中选择的值显示给select选项。
我的值是40“ X48”。 我使用的代码
<?php $pallets_type = 40"X48"; ?>
var pallets_type = "<?=htmlentities($pallets_type);?>";
$('select[name=pallets_type]').val(pallets_type);
但这对我不起作用。
答案 0 :(得分:0)
在单引号中添加双引号,例如:
$pallets_type = '40"X48"';
var pallets_type = "<?=htmlentities($pallets_type);?>";
$('select[name=pallets_type]').append('<option>"'+pallets_type+'"</option>');