源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jQuery 名称冲突的解决方法

  • 时间:2022-12-09 22:06 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jQuery 名称冲突的解决方法
jQuery 使用名为 noConflict() 的方法来解决该问题。 var jq=jQuery.noConflict(),帮助您使用自己的名称(比如 jq)来代替 $ 符号。 示例:
[u]复制代码[/u] 代码如下:
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> var jq=jQuery.noConflict(); jq(document).ready(function(){ jq("button").click(function(){ jq("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button type="button">Click me</button> </body> </html>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部