I've not looked further, though the first line of the function is invalid.
The javascript debugger of your browser would have told you that, if you'd looked.
The following things are in your way.
1)
var a=(<p>)</p>
is not valid. Try getting the innerText property of the paragraph element instead.
2) The last line of your script is also no-good. You're assigning the result of the function
validate
(which is undefined, since it doesn't return anything) to the event handler for the 'click' event, of the h3 element. Uh-uh!
3) You're trying to assign the click handler of the h3 element before the page has finished loading.That is to say - when the code has been loaded and parsed, it executes immediately - this can be well before the HTML that it references has been loaded.
4) In addition to #3 - you've also added the function as an event handler in the html - this is unnecessary. Use one method or the other. I've used an implementation that waits for the DOM to be loaded before proceeding.
Here's a few changes made that will alleviate these problems and produce and output.
<html>
<meta charset="utf-8">
<head>
<title>text</title>
<script language= "javascript">
window.addEventListener('load', onDocLoaded, false);
function onDocLoaded(evt)
{
var element=document.getElementById("biografija");
element.addEventListener('click', convert, false);
}
function convert()
{
var a = document.getElementById('tgtP').innerText;
var b="";
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>
<div id="contentwrapper">
<div id="contentcolumn">
<div class="innertube">
<h3 id="biografija" >Biografija</h3>
<p id='tgtP'>Coco Chanel, tikrasis vardas Gabrielle Bonheur Chanel; 1883 m. rugpjūčio 19 d. Somiure, Saumur – 1971 m. sausio 10 d. Paryžiuje– dizainerė, įkūrusi „Chanel" mados namus.
Ji buvo prancūzų modeliuotoja, išgarsėjusi trumpa čarlstono laikų suknele 1926 m. („maža juoda suknelė").
Chanel pirmoji atskleidė juodos spalvos elegantiškumą, rankines permetė per petį, jūreiviškus drabužius pavertė stilingu
atostogų atributu. 1954 m. jai pavyko visus nustebinti „šanel" stiliaus kostiumėliais, kurie tapo jos mados namų firminiu ženklu.
Coco Chanel vardas įamžintas ir kvepaluose „Chanel Nr. 5". Nuo 1983 m. Šanel mados namams vadovauja Karlas Lagerfeldas</p>
<h3 id="suknelė">Suknelė</h3>