for when a CMS allows users to embed script tags which pollute the global name space. jQuery in this case.
A Pen by dreamPilot on CodePen.
| <html> | |
| <head> | |
| <link rel="stylesheet" href=" //netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" /> | |
| <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
| </head> | |
| <body> | |
| <div class="jumbotron"> | |
| <div class="container"> | |
| <p>1. jquery version : </p> | |
| </div> | |
| </div> | |
| <script> | |
| $(function(){ | |
| $('p:eq(0)').append(jQuery().jquery).css("color","red"); | |
| }); | |
| </script> | |
| <script src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
| <script> var jq = $.noConflict();</script> | |
| <script> | |
| jq(function(){ | |
| jq('p:eq(1)').append(jq().jquery).css("color","blue"); | |
| }); | |
| </script> | |
| <div class="jumbotron"> | |
| <div class="container"> | |
| <p>2. jquery version : </p> | |
| </div> | |
| </div> | |
| <!-- will load just fine --> | |
| <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> | |
| </body> | |
| </html> |
for when a CMS allows users to embed script tags which pollute the global name space. jQuery in this case.
A Pen by dreamPilot on CodePen.
| body{ | |
| padding: 10%; | |
| } |