jQuery Multiple choices


Total available count: 24
Subject - JavaScript Frameworks
Subsubject - jQuery

Which jQuery method should be used to deal with name conflicts?


 

 

 

 



A


Solution:-

jQuery noConflict alias:-
In the below example you can see that the $.noConflict() method is used with a custom alias name ‘jQueryAlias‘. This code will also give you the proper output.

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
<script>
jQueryAlias = $.noConflict();
jQueryAlias (document).ready(function(){
 jQueryAlias ("button").click(function(){
 jQueryAlias ("div").fadeToggle("slow"); // this is still working
});
});
</script>
<style>
.divBlock{
width: 200px;
height: 100px;

padding: 20px;
margin: 20px;
background-color: yellow;
}
</style>
</head>

<body>

<div class="divBlock"></div>
<button>Test</button>
</body>
</html>

jQuery uses the noConflict() method to avoid the conflict of using $ variable with other JavaScript variables. The above examples will give you an idea about the usage of the noConflict method in jQuery.




Next 5 multiple choice(s)

1

Which jQuery function is used to prevent code from running, before the document is finished loading?

2

What scripting language is jQuery written in?

3

What is the correct jQuery code for making all div elements 100 pixels high?

4

Which jQuery method is used to perform an asynchronous HTTP request?

5

Which jQuery method is used to set one or more style properties for selected elements?

Comments