In other words, I would like to obtain the value of the onclick="ejemplo"
obtain the function of the onclick
In other words, I would like to obtain the value of the onclick="ejemplo"
obtain the function of the onclick
You can do it with getAttribute:
var x = document.querySelector("button").getAttribute("onclick");
Example: link
Use HTML
of jquery if you want to get the writing done in a div for example. You have other options, depending on what you refer to as value, as val()
var valor=$('#b').html();
function alertar(){
alert(valor);
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="b" onclick="alertar()">ESTO ES UN DIV</div>