最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add jquery code inside php file - Stack Overflow

programmeradmin0浏览0评论

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>

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>
Share Improve this question asked Mar 20, 2015 at 12:16 ashash 5241 gold badge8 silver badges25 bronze badges 2
  • can't use jquery code in php, it should be in script tag, why you want like that? – Ayyanar G Commented Mar 20, 2015 at 12:17
  • @AyyanarG if you are not sure, please don't misguide :) – Danyal Sandeelo Commented Mar 20, 2015 at 12:20
Add a ment  | 

2 Answers 2

Reset to default 4
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 , thank you, the changes you made didn't work but it gave me help so I change the code as bellow and it work fine.

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

评论列表(0)

  1. 暂无评论