[英]How to send a jQuery ID to Bootstrap Modal to use it in PHP function?
[英]How to use a php variable id in a jquery function?
下面的代码适用于select#B
值( B
),但不适用于select#index
的变量( $index
)。 实际上我需要id
是一个变量,并希望jQuery函数对该变量进行操作。
$(function(){
$('select#B').change(function(){
var this_value = $(this).val();
$('input#seleted_value').val(this_value);
});
});
试试吧
$("select#<?php echo $index;?>").change(function(){
var this_value = $(this).val();
$('input#seleted_value').val(this_value);
});
做这个
$("select#<?php echo $index;?>").change(function(){
var this_value = $(this).val();
$('input#seleted_value').val(this_value);
});
$('select#<?=$index?>').change(function(){
要么
$('select#<?PHP echo $index;?>').change(function(){
var selector = 'select#<?= $index ?>'; // Work only if short tag is enabled
OR
var selector = 'select#<?php echo $index ?>';
$(selector).change(function(){
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.