jQuery is JavaScript library with many pre-built functions that you can plug and use resulting in "Write Less Do More". However, you have to learn to use it. Visit
http://www.w3schools.com/jquery/[
^].
To answer your question about conversion:
document.getElementById("tgtP")
is expressed as =>
$("#tgtP")
in jQuery syntax.
innerText
=>
text();
window.addEventListener('load', onDocLoaded, false)
=>
$(document).ready(function(){
});
Go through the tutorial and you will understand them. The resulted script in jQuery will be:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
var element = $("#tgtP");
var a = element.text();
var b="";
element.click(function(){
for (i = 0; i < a.length; i++)
{
if (a.charCodeAt(i) >= 65 && a.charCodeAt(i) <= 90)
{
b = b + a.charAt(i).toLowerCase();
}
else
{
b = b + a.charAt(i).toUpperCase();
}
alert(b);
}
});
});
</script>
</head>
<body>
<p id="tgtP">aBc dEf ghIK kl</p>
</body>
</html>