[英]Change href attribute in jquery with php
$('.buttonFinish').addClass('btn btn-default');
Jquery code for the submit looks like this:提交的 Jquery 代码如下所示:
finish : $('<a>'+options.labelFinish+'</a>').attr("href","#").addClass("buttonFinish")
I need to replace "#" in href with a variable that I can send thru my PHP code.我需要用我可以通过我的 PHP 代码发送的变量替换 href 中的“#”。
I tried to do this:我试图这样做:
finish : $('<a>'+options.labelFinish+'</a>').attr("href","<?php echo $someVariable;?>").addClass("buttonFinish")
where $someVariable is defined in the PHP code where the form submission link will point to其中 $someVariable 在 PHP 代码中定义,表单提交链接将指向该代码
You can define a variable in php and call it in JS.可以在php中定义一个变量,在JS中调用。 For example...
例如...
PHP PHP
$someVariable = <?php echo $something ?>
JS JS
finish : $('<a>'+options.labelFinish+'</a>').attr("href", $someVariable).addClass("buttonFinish")
var someVariable = "<?php echo $something ?>";
finish : $('<a>'+options.labelFinish+'</a>').attr("href", someVariable).addClass("buttonFinish")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.