I am Making an editor like fiddle and I am stuck in early phase. My javascript built-in functions are not working.
HTML Code
<div class="hello">
<p>here is a paragraph</p>
</div>
<div class="content-placeholder"></div>
<div class="hello123">
<a href="#" onclick="myFunction();">Click here!</a>
</div>
Javascript Code:
function myFunction(){
alert('u r here');
}
when I post this form to preview my template containing html and javascript. Everything seems to be working fine, but javascript does not work when I click inspect element to see my code in browser, the javascript function is vanished and instead of this <a href="#" onclick="myFunction">Click here!</a>
I get like <a href="#">Click here!</a>
onclick method vanished. I am using html_entities_decode method while posting my html in controller. I am using codeigniter framework.
Remove the ; character on your onclick..copy this code below
<div class="hello">
<p>here is a paragraph</p>
</div>
<div class="content-placeholder"></div>
<div class="hello123">
<a href="#" onclick="myFunction()">Click here!</a>
</div>