Friday, May 29, 2015
The JQuery library by design uses only two global namespace so that it would not conflict with other JavaScript libraries.
Note: The thing you have to remember is that the $ is no longer referring to JQuery, it now belongs to Prototype, if you try to use Prototype and JQuery on the same page without using jQuery.noConflict(), you will get a broken page with Prototype complaining that the $ does not work. However the error is not very description as you can see below in Firefox console. You will get the TypeError: element.dispatchEvent is not a function.
Even though we've resolved the conflict, we are now left with type jQuery instead of using the $ every time we want to use jQuery. Well we can assign the object jQuery to another shorthand variable with the code below.
The code above assigns the jQuery namespace to the variable jq. It's not as cool as the $, but at least it's less typing.
- $ - the dollar is used as a reference to JQuery namespace
- Also used by Prototype library, YUI and mootools
- jQuery - is also used to reference to jQuery namespace, this the more unique reference of the two options, but nobody really uses it
So what do you do if you wanted to use jQuey and Prototype on the same page? Well jQuery can concede the $ sign to the other libraries with the code jQuery.noConflict() function
This sample code shows how jQuery gives up the $ sign to the JavaScript library Prototype
<!DOCTYPE html> <head> <meta charset="UTF-8"> <title>JQuery No Conflict</title> <script src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.2.0/prototype.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> jQuery.noConflict(); jQuery(document).ready(function(){ alert("jQuery still works!"); }); </script> </head> <body> </body> </html>
Note: The thing you have to remember is that the $ is no longer referring to JQuery, it now belongs to Prototype, if you try to use Prototype and JQuery on the same page without using jQuery.noConflict(), you will get a broken page with Prototype complaining that the $ does not work. However the error is not very description as you can see below in Firefox console. You will get the TypeError: element.dispatchEvent is not a function.
Even though we've resolved the conflict, we are now left with type jQuery instead of using the $ every time we want to use jQuery. Well we can assign the object jQuery to another shorthand variable with the code below.
<!DOCTYPE html> <head> <meta charset="UTF-8"> <title>JQuery No Conflict</title> <script src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.2.0/prototype.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> jQuery.noConflict(); var jq = jQuery; jq(document).ready(function(){ alert("jQuery still works!"); }); </script> </head> <body> </body> </html>
The code above assigns the jQuery namespace to the variable jq. It's not as cool as the $, but at least it's less typing.
Subscribe to:
Post Comments (Atom)
Search This Blog
Tags
Web Development
Linux
Javascript
DATA
CentOS
ASPNET
SQL Server
Cloud Computing
ASP.NET Core
ASP.NET MVC
SQL
Virtualization
AWS
Database
ADO.NET
AngularJS
C#
CSS
EC2
Iaas
System Administrator
Azure
Computer Programming
JQuery
Coding
ASP.NET MVC 5
Entity Framework Core
Web Design
Infrastructure
Networking
Visual Studio
Errors
T-SQL
Ubuntu
Stored Procedures
ACME Bank
Bootstrap
Computer Networking
Entity Framework
Load Balancer
MongoDB
NoSQL
Node.js
Oracle
VirtualBox
Container
Docker
Fedora
Java
Source Control
git
ExpressJS
MySQL
NuGet
Blogger
Blogging
Bower.js
Data Science
JSON
JavaEE
Web Api
DBMS
DevOps
HTML5
MVC
SPA
Storage
github
AJAX
Big Data
Design Pattern
Eclipse IDE
Elastic IP
GIMP
Graphics Design
Heroku
Linux Mint
Postman
R
SSL
Security
Visual Studio Code
ASP.NET MVC 4
CLI
Linux Commands
Powershell
Python
Server
Software Development
Subnets
Telerik
VPC
Windows Server 2016
angular-seed
font-awesome
log4net
servlets
tomcat
AWS CloudWatch
Active Directory
Angular
Blockchain
Collections
Compatibility
Cryptocurrency
DIgital Life
DNS
Downloads
Google Blogger
Google Chrome
Google Fonts
Hadoop
IAM
KnockoutJS
LINQ
Linux Performance
Logging
Mobile-First
Open Source
Prototype
R Programming
Responsive
Route 53
S3
SELinux
Software
Unix
View
Web Forms
WildFly
XML
cshtml
githu
https://www.youtube.com/watch?v=j3ZlN0r9dxI
ReplyDeleteI would like to say that this blog really convinced me to do it! Thanks, very good post. Search Bar Firefox 57 Quantum addon
ReplyDeleteMua vé máy bay tại Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ tháng nào rẻ nhất
vé máy bay từ mỹ về việt nam
chuyến bay thương mại từ canada về việt nam
vé máy bay nhật việt
ve may bay tu han quoc ve viet nam
Vé máy bay từ Đài Loan về VN
chuyến bay dành cho chuyên gia
LEGIT FULLZ & TOOLS STORE
ReplyDeleteHello to All !
We are offering all types of tools & Fullz on discounted price.
If you are in search of anything regarding fullz, tools, tutorials, Hack Pack, etc
Feel Free to contact
***CONTACT 24/7***
**Telegram > @leadsupplier
**ICQ > 752822040
**Skype > Peeterhacks
**Wicker me > peeterhacks
"SSN LEADS/FULLZ AVAILABLE"
"TOOLS & TUTORIALS AVAILABLE FOR HACKING, SPAMMING,
CARDING, CASHOUT, CLONING, SCRIPTING ETC"
**************************************
"Fresh Spammed SSN Fullz info included"
>>SSN FULLZ with complete info
>>CC With CVV (vbv & non vbv) Fullz USA
>>FULLZ FOR SBA, PUA & TAX RETURN FILLING
>>USA I.D Photos Front & Back
>>High Credit Score fullz (700+ Scores)
>>DL number, Employee Details, Bank Details Included
>>Complete Premium Info with Relative Info
***************************************
COMPLETE GUIDE FOR TUTORIALS & TOOLS
"SPAMMING" "HACKING" "CARDING" "CASH OUT"
"KALI LINUX" "BLOCKCHAIN BLUE PRINTS" "SCRIPTING"
"FRAUD BIBLE"
"TOOLS & TUTORIALS LIST"
=>Ethical Hacking Ebooks, Tools & Tutorials
=>Bitcoin Hacking
=>Kali Linux
=>Fraud Bible
=>RAT
=>Keylogger & Keystroke Logger
=>WhatsApp Hacking & Hacked Version of WhatsApp
=>Facebook & Google Hacking
=>Bitcoin Flasher
=>SQL Injector
=>Premium Logs (PayPal/Amazon/Coinbase/Netflix/FedEx/Banks)
=>Bitcoin Cracker
=>SMTP Linux Root
=>Shell Scripting
=>DUMPS with pins track 1 and 2 with & without pin
=>SMTP's, Safe Socks, Rdp's brute
=>PHP mailer
=>SMS Sender & Email Blaster
=>Cpanel
=>Server I.P's & Proxies
=>Viruses & VPN's
=>HQ Email Combo (Gmail, Yahoo, Hotmail, MSN, AOL, etc.)
*Serious buyers will always welcome
*Price will be reduce in bulk order
*Discount offers will give to serious buyers
*Hope we do a great business together
===>Contact 24/7<===
==>Telegram > @leadsupplier
==>ICQ > 752822040
==>Skype > Peeterhacks
==>Wicker me > peeterhacks