简体   繁体   中英

How to add jquery code inside php file

I search Google and find lots of link for similar but none help me,,, how to add a piece of jquery code inside <?php......?>

here's my code

<script type="text/javascript"> var $j = jQuery.noConflict();
    $j(document).ready(function(){$j('.number').Number();});</script>
echo "<script type='text/javascript'> var $j = jQuery.noConflict();
$j(document).ready(function(){$j('.number').Number();});</script>";

Just echo the jquery or javascript, you have to make sure that you don't break the string while echoing the javascript or jquery

@Danyal Sandeelo,谢谢,您所做的更改没有用,但是它为我提供了帮助,因此我将代码更改为下面的代码,它可以正常工作。

echo "<script type=\"text/javascript\">var $j = jQuery.noConflict();$j(document).ready(function(){$j('.number').Number();});    </script>";

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM